home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
ms_dos
/
nifp
/
nifp.c
next >
Wrap
C/C++ Source or Header
|
1993-07-08
|
101KB
|
4,576 lines
/*
* NIFTYログ専用簡単ページャ V3.71
*
*
* BORLAND TURBO C V2.0で作成しました。
*
* 著作権はやなさん(NIFTY-Serve:GHC00073)が所有しています。
*
* 98用コンパイル方法
* make -f nifpmake.98
* FM用コンパイル方法
* make -f nifpmake.fm
* AT用コンパイル方法
* make -f nifpmake.at
*
* ソースファイル構成は,
* nifp.c nifplog.c nifpsub.c nifptool.c nifp.h
* タブ数は4カラムとなっています。
* TURBO Cでリンクする時には,引き数にワイルドカードが使えるようにライブラリを編集して
* ください。
*/
/*
* このモジュールは,NIFPのメイン部です。主にタイトル一覧表示と内容表示を処理します。
* このモジュールは,マシン依存していません。
*/
#include "nifp.h"
char *cfgversion = "1.40";
PCELL far *p_top=(PCELL far *)0; /* タイトルテーブル先頭ポインタ */
PCELL far *p_head=(PCELL far *)0; /* タイトルテーブル処理中先頭ポインタ */
PCELL far *p_tail=(PCELL far *)0; /* タイトルテーブル最終ポインタ */
char filename[129],gfilename[13]; /* 処理中ログファイル名 */
long saveatime=0;
int fupmode = 0;
union REGS regs; /* DOS用レジスタ群 */
struct SREGS sregs; /* DOS用セグメントレジスタ群 */
char far *buf1[MAXLINE]; /* 内容表示用行バッファポインタ */
char fbuf1[MAXLINE]; /* 内容表示用行フラグ */
char far *file[FMAXFILE]; /* 複数ファイル用テーブル */
FILE *fd; /* 処理中ログファイルFD */
long p,p_linecount=0,savep,sentakuno=0,sakujyono=0,tagno=0;
char nmode,savecon,nifmode,savenmode,bunmode=0,foutmode=0;
char tagmode=0;
char titlemode=0;
char datfile[129] = "\\NIFP.DAT";
char far *datf[MAXDATF]; /* 未読記憶ファイル用ファイル名+既読数テーブル */
long midokuno=0;
int savepno;
int cfno,fno,maxfno;
int line = 0,saveline;
int typespeed = 20;
int startmode = 0;
int waittimes = 3;
int titlecount = 20;
int vrammode = 0;
int fsortmode = 0;
int fsort2mode = 0;
int autodisptime = 5;
int autodisptime2 = 5;
char autodispsw = 0;
char pagemode = 0;
char sepamode = 0;
char editer[41] = "VZ";
char kiridir[51] = "";
char hatudir[51] = "";
char titledir[51] = "";
char printprg[41] = "PRINT";
char messtring[2][4][21];
char bakdir[51] = "";
char far *logdir[LOGDIRMAX];
char cmdtbl[15][41];
char treechar[12] = "+- +- | +-";
char touttop[129] = "";
char prtsepa[129] = "^J";
char kiridashitop[3][257];
char hatutop[2][4][257];
char hatuend[2][4][257];
char keytbl[256] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00 */
0x08,0x09,0x00,0x00,0x00,0x0d,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 10 */
0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x00,
0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 20 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 30 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xca,0xc1,0x00,0x00, /* 40 */
0x84,0x00,0x00,0x00,0x00,0x00,0x00,0xc6,
0xc7,0x00,0x00,0x00,0xc2,0x00,0x00,0x00, /* 50 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xca,0xc1,0x00,0x00, /* 60 */
0x84,0x00,0x00,0x00,0x00,0x00,0x00,0xc6,
0xc7,0x00,0x00,0x00,0xc2,0x00,0x00,0x00, /* 70 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x81,0x82,0x83,0x84,0x85,0x86,0x87, /* 80 */
0x88,0x89,0x8a,0xc2,0x84,0xc6,0xc7,0xc1,
0x90,0x91,0x92,0x93,0x90,0x91,0x82,0x84, /* 90 */
0x87,0x86,0x0d,0x1b,0xa2,0x00,0xa3,0x1b,
0xaa,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7, /* A0 */
0xa8,0xa9,0xaa,0x00,0x00,0x00,0x00,0x00,
0x82,0x83,0xa2,0xa3,0x90,0x91,0x83,0x84, /* B0 */
0x87,0x86,0x00,0x00,0xa2,0x00,0xa3,0x00,
0x00,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7, /* C0 */
0xc8,0xc9,0xca,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* D0 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xca,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* E0 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xf5,0xf6,0xf7, /* F0 */
0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0x00 };
char irotbl[IROMAX] = { 15,13,14,12,5,13,7,15,5,13,2,10,7,12,
15,12,10,12,12,12,1,9,2,10,3,11,39,47,
6,14,1,5,15,13,15,7,6,4,2 };
int endmode = 1;
int tabno = 8;
int topendmode = 0;
int yesnomode = 1;
int sakujyomode = 0;
int editmode = 0;
int nextmode = 0;
int tabcrmode = 1;
int jikokumode = 2;
int cutmode = 0;
int returnmode = 0;
int keyshiftmode = 0;
int midokumode = 0;
int passmode = 0;
int timechkmode = 1;
PCELL far *rsv_p = (PCELL far *)0;
char savsafix[4]="SAV";
char nifsafix[4]="NIF";
char ESCin[10]="";
char ESCout[10]="";
char far *cutstrtbl[MAXCUTNO]; /* カット文字列登録テーブル */
char far *msgstrtbl[MAXMSGNO]; /* フォーラム3回メッセージ文字列登録テーブル */
int emsno = 0;
int ems_count = 0;
int ems_lno = -1;
int ems_handle = 0;
long ems_seg = 0;
PCELL far *p_freetop = (PCELL far *)0;
PCELL3 far *p_tbltop = (PCELL3 far *)0;
int savekeymode;
int keta=1,gyo=1,tmode=0;
long vramoffset;
int kensakukensu=0;
PCELL far *ttop;
PCELL far *ttail;
PCELL far *ggtop;
PCELL far *ggtail;
PCELL far *gpo;
char nifid[9];
char kensakumoji[39]="";
char *space=" ";
char *toperror="先頭です";
char *enderror="最終です";
char *cancelerror="取り消しができません";
char *tagseterror="タグ設定ができません";
char *tagnoterror="タグが見つかりません";
char *filenoterror="ファイルがありません";
char *keyerror="無効なキー入力です";
char *bunnasierror="内容がありません";
char *notcomenterror="ここではコメント機能は無効です";
char *notiderror="IDがないので無効です";
char *etckeymsg="何かキーを押してください";
char *filenoerror="指定ファイルがありません。";
char *srcmsg="只今、検索中です。しばらくお待ちください。";
char *memgeterror="メモリ獲得に失敗";
static int sethatu(); /* 発言ヘッダフッタ出力 */
void xhpread(int count)
{
if(count <= p) return;
if(count == MAXPOINT) hpread(count,1);
else hpread(count-p,0);
ttail = p_tail;
}
static void buffreesub(int k) /* 内容表示バッファ返却(1行) */
{
farfree(buf1[k]);
buf1[k] = 0;
}
static void bunbuffree(void) /* 内容表示バッファ返却 */
{
int k;
for(k=0;buf1[k] && k < MAXLINE;k++)
buffreesub(k);
}
static int fputsub(char *buf,FILE *fd1,char *fname) /* ファイル出力サブルーチン */
{
char errbuf[81];
if(fputs(buf,fd1) == EOF) {
sprintf(errbuf,"%sファイルの書き出し失敗",fname);
errdisp2(errbuf);
fclose(fd1);
return(-1);
}
return(0);
}
extern int defline;
static void chgline(PCELL far *tcu) /* 行数切り換え */
{
xhpread(tcu->count+line);
if(line != defline) chglowline();
else chghighline();
line = getline();
csloff();
}
static int check_fup(void)
{
char a[81];
struct stat sbuf;
if(startmode == 8) return(0);
if(stat(filename,&sbuf)) {
sprintf(a,"%sファイルが削除されたので,終了します",gfilename);
errdisp2(a);
return(-2);
}
if(sbuf.st_atime != saveatime) {
sprintf(a,"%sファイルが変更されたので,読み直します",gfilename);
errdisp2(a);
return(-1);
}
return(0);
}
static void systemcall(char *sys,char *buf) /* DOSコマンド呼び出し */
{
int c;
char c_dir[256];
c = getdisk();
getcwd(c_dir,255);
allclr();
restorecon(0);
setline(saveline);
cslon();
if(strlen(buf)) printf(buf);
system(sys);
ems_lno = -1;
allclr();
setdisk(c);
chdir(c_dir);
setcon(0);
setline(line);
}
static int oscall(void) /* DOS呼び出し */
{
systemcall("","\nexitで元に戻ります。\n");
return(check_fup());
}
static char printonoff=0;
static void prt_sub0(char *template,char *fname) /* 印刷用ファイル名作成&フラグON */
{
char *tmp;
tmp = getenv("TMP");
if(tmp) {
strcpy(template,tmp);
if(template[strlen(template)-1] != '\\')
strcat(template,"\\");
}
else strcpy(template,"\\");
strcat(template,"$PRXXXXXX");
strcpy(&fname[2],mktemp(template));
printonoff = 1;
}
static void prt_sub(char *fname) /* 印刷サブルーチン */
{
char sys[256];
xlocate();
/* kprintf("印刷中です。"); */
sprintf(sys,"%s %s",printprg,fname);
systemcall(sys,"\n印刷中です。\n");
}
static char linework[6] = "";
FILE *fopen_sub(char *fname,int mode) /* 追加ファイルオープン */
{
FILE *fd1;
int f,i=0,l=1;
char a[300];
strcpy(linework,"1");
if(fd1 = fopen(fname,"rt")) {
if(mode) {
while(fgets(a,300,fd1))
l++;
sprintf(linework,"%ld",l);
}
if(!fseek(fd1,-1,SEEK_END))
if(fgetc(fd1) == EOF) i = -1;
fclose(fd1);
if((f = open(fname,O_WRONLY|O_TEXT)) == -1) {
sprintf(a,"%sファイルのオープンに失敗",fname);
errdisp2(a);
return(0);
}
fd1 = fdopen(f,"at");
fseek(fd1,i,SEEK_END);
return(fd1);
}
return(xxfopen(fname, "at"));
}
static void grh_dispx(char *buf,int mode)
{
char b[81];
grh_disp(buf,mode);
sprintf(b,"只今、%sです。",buf);
xlocate();
kprintf(b);
}
static int titleout(void) /* タイトル一覧ファイル出力 */
{
FILE *fd1;
PCELL far *pt;
char fname[53],buf[81],template[53];
int j;
template[0] = 0;
xhpread(MAXPOINT);
sprintf(buf,"タイトル出力先ファイル名 = ");
fname[0] = 50;
strcpy(&fname[2],titledir);
cgetfsx(buf, fname);
if(!fname[2])
return(0);
if(!strcmp(&fname[2],"PRT")) {
prt_sub0(template,fname);
}
if(!(fd1 = fopen_sub(&fname[2],0)))
return(0);
if(strlen(touttop)) {
if(!sethatu(touttop,fd1,&fname[2],1)) /* ヘッダ出力 */
return(0);
}
grh_dispx("タイトル出力処理中",1);
for(pt = p_head,j=1;pt->mode != NEND;pt = pt->next) {
if(!pt->count) continue;
/* xlocate();
sprintf(buf,"只今、%d/%dタイトル目を出力中です。",j,p_tail->count-1);
kprintf(buf); */
tbl_set(pt);
_fstrcpy((char far *)buf,pt->p->title);
strcat(buf,"\n");
if(fputsub(buf,fd1,&fname[2])) {
return(1);
}
if(keycheck() && getch() == 0x1b) break;
if(!(j % 10)) grh_sub(j++,p_tail->count-1);
}
grh_sub(1,1);
fclose(fd1);
if(strlen(template))
prt_sub(&fname[2]);
else
xxstrncpy50(titledir,&fname[2]);
return(1);
}
static char kirititle[81];
static int sethatusub(char *a,char *b) /* 引用格納サブルーチン */
{
int i,j;
if(!strlen(b)) return(0);
for(i=j=0;b[i];i++)
a[j++] = b[i];
a[j] = 0;
return(j);
}
static int fukusyasub(PCELL far *tcu,int mode) /* 切り出し・コピー・印刷サブルーチン */
{
FILE *fd1;
PCELL far *pt;
char fname[53],buf[81],sys[101],*usercmd,template[53];
int i,j,k,m,x=0;
template[0] = 0;
if(!sentakuno) {
tbl_set(tcu);
/* if(tcu->mode == NEND || tcu->mode == NSEPA) */
if(tcu->mode == NEND || tcu->p->top == tcu->p->tail)
return(0);
tcu->flag |= FSENTAKU;
sentakuno++;
x = 1;
}
if(mode == 2) {
sprintf(buf,"%d件の内容を印刷しますか",sentakuno);
if(!yesnocheck(buf)) {
copy_err:
if(x) {
tcu->flag &= ~FSENTAKU;
sentakuno--;
}
return(0);
}
}
else {
sprintf(buf,"%d件の",sentakuno);
if(!mode) strcat(buf,"コピー先ファイル名 = ");
else strcat(buf,"切り出し先ファイル名 = ");
fname[0] = 50;
strcpy(&fname[2],kiridir);
cgetfsx(buf, fname);
if(!fname[2]) {
goto copy_err;
}
}
if(mode == 2 || !(strcmp(&fname[2],"PRT"))) {
prt_sub0(template,fname);
}
if(!(fd1 = fopen_sub(&fname[2],1)))
goto copy_err;
bunbuffree();
for(pt=p_head;sentakuno && pt->mode != NEND;pt=pt->next)
if((pt->flag & FSENTAKU)) break;
pt = pt->grp;
tbl_set(pt);
_fstrcpy((char far *)kirititle,pt->p->title);
if(mode != 2 && strlen(kiridashitop[1])) {
if(!sethatu(kiridashitop[1],fd1,fname,1)) /* ヘッダ出力 */
goto copy_err;
}
if(!mode) {
grh_dispx("コピー処理中",1);
}
else {
grh_dispx("切り出し処理中",1);
}
for(pt=p_top,j=1,x=sentakuno;sentakuno && pt->mode != NEND;pt=pt->next) {
if(!(pt->flag & FSENTAKU)) continue;
/* xlocate();
sprintf(buf,"只今、%d/%dタイトル目を出力中です。",j,x);
kprintf(buf); */
tbl_set(pt);
if(pt->p->top == pt->p->tail) {
_fstrcpy((char far *)buf,pt->p->title);
strcat(buf,"\n");
if(fputsub(buf,fd1,&fname[2])) {
return(1);
}
}
else {
if(m = bunget(pt,0)) {
for(k=0;k < m-1;k++) {
_fstrcpy((char far *)buf,buf1[k]);
buffreesub(k);
if(fputsub(buf,fd1,&fname[2])) {
for(;buf1[k] && k < MAXLINE;k++) {
buffreesub(k);
}
return(1);
}
}
}
}
if(mode == 2) {
if(!sethatu(prtsepa,fd1,&fname[2])) {
return(1);
}
}
if(keycheck() && getch() == 0x1b) break;
grh_sub(j++,x);
pt->flag &= ~FSENTAKU;
sentakuno--;
if(mode == 1) {
if(!(pt->flag & FSAKUJYO)) {
pt->flag |= FSAKUJYO;
sakujyono++;
}
}
}
if(mode != 2 && strlen(kiridashitop[2])) {
if(!sethatu(kiridashitop[2],fd1,fname,1)) /* フッタ出力 */
goto copy_err;
}
fclose(fd1);
if(strlen(template)) {
prt_sub(&fname[2]);
return(1);
}
xxstrncpy50(kiridir,&fname[2]);
usercmd = kiridashitop[0];
if(strlen(usercmd)) {
for(i=j=0;usercmd[i];i++) {
if(iskanji(usercmd[i]) && iskanji2(usercmd[i+1])) {
sys[j++] = usercmd[i++];
sys[j++] = usercmd[i];
continue;
}
/* if(usercmd[i] == '$' && usercmd[i+1] == 'f') {
k = sethatusub(&sys[j],&fname[2]);
i++;
j += k;
continue;
} */
if(usercmd[i] == '$') {
switch(usercmd[++i]) {
case 'f': k = sethatusub(&sys[j],&fname[2]);
break;
case 'l': k = sethatusub(&sys[j],linework);
break;
default: sys[j] = usercmd[i]; k = 1; break;
}
j += k;
continue;
}
sys[j++] = usercmd[i];
}
sys[j] = 0;
systemcall(sys,"");
}
return(1);
}
static int fukusya(PCELL far *tcu) /* コピー */
{
return(fukusyasub(tcu,0));
}
static int kiridasi(PCELL far *tcu) /* 切り出し */
{
return(fukusyasub(tcu,1));
}
static int printsub(PCELL far *tcu) /* 印刷サブルーチン */
{
return(fukusyasub(tcu,2));
}
static int sakujyo(PCELL far *tcu) /* 削除 */
{
PCELL far *pt;
char buf[81];
if(!sentakuno) {
if(tcu->flag & FSAKUJYO) {
tcu->flag &= ~FSAKUJYO;
sakujyono--;
return(2);
}
if(tcu->mode == NEND)
return(0);
/* if(tcu->mode == NSEPA) */
tbl_set(tcu);
if(tcu->p->top == tcu->p->tail)
return(2);
tcu->flag |= FSAKUJYO;
sakujyono++;
return(2);
}
sprintf(buf,"%d件を削除指定しますか",sentakuno);
if(!yesnocheck(buf)) return(0);
for(pt=p_top;sentakuno && pt->mode != NEND;pt=pt->next) {
if(!(pt->flag & FSENTAKU)) continue;
pt->flag &= ~FSENTAKU;
sentakuno--;
if(pt->flag & FSAKUJYO) continue;
pt->flag |= FSAKUJYO;
sakujyono++;
}
return(1);
}
static int
cmdfilesub(PCELL far *tcu,char *fname,int mode) /* コマンド用ファイル出力 */
{
FILE *fd1;
PCELL far *pt;
PCELL far *w;
char a,buf[81],template[53],work[9];
int i,j,k,m,x=0;
char *tmp;
template[0] = 0;
if(!sentakuno) {
tbl_set(tcu);
/* if(tcu->mode == NEND || tcu->mode == NSEPA) */
if(tcu->mode == NEND || tcu->p->top == tcu->p->tail)
return(0);
tcu->flag |= FSENTAKU;
sentakuno++;
x = 1;
}
tmp = getenv("TMP");
if(tmp) {
strcpy(template,tmp);
if(template[strlen(template)-1] != '\\')
strcat(template,"\\");
}
else strcpy(template,"\\");
strcpy(&fname[2],template);
if(!mode) {
memset(work,0,9);
w = tcu->grp;
tbl_set(w);
_fmemcpy((char far *)work,w->p->nifid,8);
}
else {
for(i=j=0;(j < 8) && (a=gfilename[i++]) && (a != '.');) {
work[j++] = a;
}
work[j] = 0;
}
if(strlen(work)) strcat(&fname[2],work);
else strcat(&fname[2],"NIFP");
strcat(&fname[2],".@_@");
if(!(fd1 = fopen_sub(&fname[2],0))) {
copy_err:
if(x) {
tcu->flag &= ~FSENTAKU;
sentakuno--;
}
return(0);
}
bunbuffree();
grh_dispx("テンポラリーファイル出力処理中",0);
for(pt=p_top,j=1,x=sentakuno;sentakuno && pt->mode != NEND;pt=pt->next) {
if(!(pt->flag & FSENTAKU)) continue;
/* xlocate();
sprintf(buf,"只今、%d/%dタイトル目を出力中です。",j,x);
kprintf(buf); */
tbl_set(pt);
if(pt->p->top == pt->p->tail) {
_fstrcpy((char far *)buf,pt->p->title);
strcat(buf,"\n");
if(fputsub(buf,fd1,&fname[2])) {
return(0);
}
}
else {
if(m = bunget(pt,0)) {
for(k=0;k < m-1;k++) {
_fstrcpy((char far *)buf,buf1[k]);
buffreesub(k);
if(fputsub(buf,fd1,&fname[2])) {
for(;buf1[k] && k < MAXLINE;k++) {
buffreesub(k);
}
return(0);
}
}
}
}
grh_sub(j++,x);
pt->flag &= ~FSENTAKU;
sentakuno--;
}
grh_sub(1,1);
fclose(fd1);
return(1);
}
static int usertouroku(PCELL far *tcu,int lno) /* 利用者コマンド処理 */
{
int i,c;
char buf[256],c_dir[256],c_file[256];
if((i = comand_disp(tcu,lno)) == -1) return(0);
if(strstr(cmdtbl[i],"$p")) {
if(!cmdfilesub(tcu,c_file,0)) return(0);
}
else if(strstr(cmdtbl[i],"$P")) {
if(!cmdfilesub(tcu,c_file,1)) return(0);
}
else c_file[2] = 0;
set_cmdcopy(buf,i,tcu,&c_file[2],lno);
c = getdisk();
getcwd(c_dir,255);
allclr();
restorecon(0);
setline(saveline);
cslon();
system(buf);
allclr();
ems_lno = -1;
if(!strstr(cmdtbl[i],"$K")) {
locate(1,line-1);clr();
kprintf(etckeymsg);
keyget();
}
setdisk(c);
chdir(c_dir);
setcon(0);
setline(line);
if(c_file[2] != 0) {
remove(&c_file[2]);
if(i=check_fup()) return(i);
return(1);
}
return(check_fup());
}
static int torikesi(void) /* 選択取消 */
{
PCELL far *pt;
char b[39];
if(sentakuno) {
sprintf(b,"%d件の選択を取り消しますか",sentakuno);
if(!yesnocheck(b)) return(1);
}
else {
errdisp1(cancelerror);
return(0);
}
for(pt=p_top;sentakuno && pt->mode != NEND;pt=pt->next) {
if(!(pt->flag & FSENTAKU)) continue;
pt->flag &= ~FSENTAKU;
sentakuno--;
}
return(1);
}
static int sakutorikesi(void) /* 削除取消 */
{
PCELL far *pt;
char b[39];
int i,mode=0;
if(sakujyono) {
for(i=0,pt=p_top;pt && pt->mode != NEND;pt=pt->next) {
if((pt->flag & FSAKUJYO) && (pt->flag & FSENTAKU)) i++;
}
if(i) mode = 1;
else i = sakujyono;
sprintf(b,"%d件の削除指定を取り消しますか",i);
if(!yesnocheck(b)) return(1);
}
else {
errdisp1(cancelerror);
return(0);
}
for(pt=p_top;i && pt->mode != NEND;pt=pt->next) {
if(!(pt->flag & FSAKUJYO)) continue;
if(mode) {
if(pt->flag & FSENTAKU) {
pt->flag &= ~FSENTAKU;
sentakuno--;
}
else continue;
}
pt->flag &= ~FSAKUJYO;
sakujyono--;
i--;
}
return(1);
}
char YEAR[5],year[3],mon[3],mon2[2],mday[3],hour1[3],hour2[3],min[3],sec[3],ampm[3];
void dateget(void) { /* 現在時刻読み込み */
struct tm *jtime;
time_t ltime[1];
int w;
time(ltime);
jtime = localtime(ltime);
if(jtime->tm_year > 70) sprintf(YEAR,"19%02d",jtime->tm_year);
else sprintf(YEAR,"20%02d",jtime->tm_year);
sprintf(year,"%02d",jtime->tm_year);
w = jtime->tm_mon+1;
sprintf(mon,"%02d",w);
if(w < 10) sprintf(mon2,"%d",w);
else sprintf(mon2,"%c",w+'A'-10);
sprintf(mday,"%02d",jtime->tm_mday);
sprintf(hour1,"%02d",jtime->tm_hour);
if(jtime->tm_hour < 12) {
sprintf(hour2,"%02d",jtime->tm_hour);
strcpy(ampm,"AM");
}
else {
sprintf(hour2,"%02d",jtime->tm_hour-12);
strcpy(ampm,"PM");
}
sprintf(min,"%02d",jtime->tm_min);
sprintf(sec,"%02d",jtime->tm_sec);
}
static char hatutitle[81];
static char hatunifid[9];
static char hatuhpid[9];
static char hatuheyano[3];
static char hatucmtno[6];
static char hatucmtno2[6];
static char hatuforum[9];
static char hatuhandle[19];
static int
sethatu(char *s,FILE *fd1,char *fname,int mode) /* 発言ヘッダフッタ出力 */
{
char c,buf[513],w[9];
int i,j,k;
dateget();
for(i=j=0;(c=gfilename[i++]) && (c != '.');) {
w[j++] = c;
}
w[j] = 0;
for(i=j=0;s[i] && j < 512;i++) {
if(iskanji(s[i]) && iskanji2(s[i+1])) {
buf[j++] = s[i++];
buf[j++] = s[i];
continue;
}
if(s[i] == '$') {
switch(s[++i]) {
case 's': rtncut(hatutitle);
k = sethatusub(&buf[j],hatutitle);
break;
case 'i': k = sethatusub(&buf[j],hatunifid);
break;
case 'I': k = sethatusub(&buf[j],hatuhpid);
break;
case 'n': k = sethatusub(&buf[j],hatuheyano);
break;
case 'c': k = sethatusub(&buf[j],hatucmtno);
break;
case 'C': k = sethatusub(&buf[j],hatucmtno2);
break;
case 'f': k = sethatusub(&buf[j],gfilename);
break;
case 'x': k = sethatusub(&buf[j],w);
break;
case 'h': k = sethatusub(&buf[j],hatuhandle);
break;
case 'F': k = sethatusub(&buf[j],hatuforum);
break;
case 't': k = sethatusub(&buf[j],kirititle);
break;
case 'y': k = sethatusub(&buf[j],YEAR);
break;
case 'Y': k = sethatusub(&buf[j],year);
break;
case 'T': k = sethatusub(&buf[j],mon);
break;
case 'D': k = sethatusub(&buf[j],mday);
break;
case 'H': k = sethatusub(&buf[j],hour1);
break;
case 'J': k = sethatusub(&buf[j],hour2);
break;
case 'M': k = sethatusub(&buf[j],min);
break;
case 'S': k = sethatusub(&buf[j],sec);
break;
case 'P': k = sethatusub(&buf[j],ampm);
break;
case 'a': k = sethatusub(&buf[j],mon2);
break;
default: buf[j] = s[i]; k = 1; break;
}
j += k;
continue;
}
if(s[i] == '\\' && s[i+1] == 'n') {
buf[j++] = '\n';
i++;
continue;
}
if(s[i] == '^') {
c = s[++i];
if(c >= '@' && c <= '_') {
if(c == '^') buf[j++] = c;
else buf[j++] = c - '@';
}
else {
buf[j++] = '^';
buf[j++] = c;
}
continue;
}
buf[j++] = s[i];
}
if(mode && strlen(buf) && buf[j-1] != '\n')
buf[j++] = '\n';
buf[j] = 0;
if(fputsub(buf,fd1,fname)) return(0);
return(strlen(buf));
}
static int hatugen(PCELL far *tcu,int no) /* 発言出力 */
{
FILE *fd1;
char fname[53],buf[161],sys[161],*s;
int i,k,mode,l;
PCELL far *pt;
PCELL far *w;
if(tcu->mode == NEND)
return(0);
if(!no) sprintf(buf, "発言先ファイル名 = ");
else sprintf(buf, "発言2先ファイル名 = ");
fname[0] = 50;
strcpy(&fname[2],hatudir);
cgetfsx(buf, fname);
if(!fname[2]) {
return(0);
}
if(!(fd1 = fopen_sub(&fname[2],1)))
return(0);
memset(buf,0,101);
hatutitle[0] = 0;
tbl_set(tcu);
_fmemcpy((char far *)hatunifid,tcu->p->nifid,8);
memset(hatuhpid,0,9);
hatuheyano[0] = 0;
sprintf(hatucmtno,"%d",tcu->p->id);
if(tcu->flag & FCYCLE) sprintf(hatucmtno2,"%05u",tcu->p->id);
else sprintf(hatucmtno2,"%03d",tcu->p->id);
hatuforum[0] = 0;
hatuhandle[0] = 0;
switch(tcu->mode) {
case NHP:
mode = 0;
if(!strlen(hatutop[no][0])) break;
w = tcu->grp;
tbl_set(w);
_fstrcpy((char far *)buf,w->p->title);
if(isalpha(buf[9])) strncpy(hatuhpid,&buf[9],8);
_fstrcpy((char far *)hatutitle,&buf1[0][37]);
if(!sethatu(hatutop[no][0],fd1,fname,1)) return(0);
break;
case NMAIL:
mode = 1;
if(!strlen(hatutop[no][1])) break;
if(buf1[0][0] == '-') { /* air craft mail ? */
_fstrcpy((char far *)hatutitle,&buf1[2][10]);
_fstrncpy((char far *)buf,&buf1[1][4],18);
}
else {
_fstrcpy((char far *)hatutitle,&buf1[1][10]);
_fstrncpy((char far *)buf,&buf1[0][4],18);
}
for(i=17;i;i--) {
if(buf[i] == ' ') continue;
if(iskanji(buf[i-1])) {
k = (buf[i] * 256) + buf[i-1];
if(k == ' ') {
i--;
continue;
}
break;
}
break;
}
buf[i+1] = 0;
strcpy(hatuhandle,buf);
hatunifid[8] = 0;
if(!sethatu(hatutop[no][1],fd1,fname,1)) return(0);
break;
case NFORUM:
mode = 2;
if(!strlen(hatutop[no][2])) break;
if(!(tcu->flag & FCYCLE)) {
_fstrcpy((char far *)hatutitle,&buf1[0][38]);
_fstrncpy((char far *)buf,&buf1[0][20],18);
}
else {
_fstrcpy((char far *)hatutitle,&buf1[0][39]);
_fstrncpy((char far *)buf,&buf1[0][22],17);
}
for(i=17;i;i--) {
if(!buf[i] || buf[i] == ' ') continue;
if(iskanji(buf[i-1])) {
k = (buf[i] * 256) + buf[i-1];
if(k == ' ') {
i--;
continue;
}
break;
}
break;
}
buf[i+1] = 0;
strcpy(hatuhandle,buf);
_fstrcpy((char far *)buf,&buf1[1][0]);
s = jstrchr(buf,'(');
s[3] = 0;
if(s[1] == ' ') strcpy(hatuheyano,&s[2]);
else strcpy(hatuheyano,&s[1]);
pt = tcu->grp;
tbl_set(pt);
_fstrcpy((char far *)buf,pt->p->title);
xstrncpy(hatuforum,&buf[2]);
if(!sethatu(hatutop[no][2],fd1,fname,1)) return(0);
break;
case NBBS:
case NFBBS:
mode = 3;
if(!strlen(hatutop[no][3])) break;
_fstrcpy((char far *)hatutitle,&buf1[0][30]);
if(!sethatu(hatutop[no][3],fd1,fname,1)) return(0);
break;
default:
mode = 4;
}
if(strcmp(messtring[no][mode],"$d")) {
memset(sys,0,81);
for(k=0;buf1[k];k++) {
if(mode <= 3 && strlen(messtring[no][mode])) {
if(!(i=sethatu(messtring[no][mode],fd1,fname,0))) return(0);
memset(buf,0,81);
strcpy(buf,sys);
_fstrcpy((char far *)sys,buf1[k]);
l = strlen(sys);
strcat(buf,sys);
memset(sys,0,81);
if(i+l > 77) {
l = 77-i;
if(buf[l] != '\n') {
if(nthctype(buf,l-1) == CT_KJ1)
l++;
strcpy(sys,&buf[l]);
buf[l] = 0;
strcat(buf,"\n");
}
}
if(fputsub(buf,fd1,fname)) return(0);
if(strchr(sys,'\n')) {
if(!(i=sethatu(messtring[no][mode],fd1,fname,0)))
return(0);
if(fputsub(sys,fd1,fname)) return(0);
memset(sys,0,81);
}
}
else {
_fstrcpy((char far *)buf,buf1[k]);
if(fputsub(buf,fd1,fname)) return(0);
}
}
}
if(mode <= 3) {
if(strlen(hatuend[no][mode])) {
if(!sethatu(hatuend[no][mode],fd1,fname,1)) return(0);
}
}
fclose(fd1);
if(!strstr(editer,"$p")) sprintf(sys,"%s %s",editer,&fname[2]);
else {
s = editer;
for(i=l=0;s[i];i++) {
if(iskanji(s[i]) && iskanji2(s[i+1])) {
sys[l++] = s[i++];
sys[l++] = s[i];
continue;
}
if(s[i] == '$') {
switch(s[++i]) {
case 'p': k = sethatusub(&sys[l],&fname[2]);
break;
case 'l': k = sethatusub(&sys[l],linework);
break;
default: sys[l] = s[i]; k = 1; break;
}
l += k;
continue;
}
sys[l++] = s[i];
}
sys[l] = 0;
}
systemcall(sys,"");
xxstrncpy50(hatudir,&fname[2]);
return(1);
}
static PCELL far *work_top;
static PCELL far *work_tail;
static PCELL far *free_top;
static PCELL far *free_tail;
static PCELL far *cmt_top;
static PCELL far *cmt_tail;
static char cmt_tbl[41];
static void cmtfree(PCELL far *d) /* セル返却 */
{
tbl_free(d);
}
static void cmtdelete(PCELL far *d) /* タイトルキュー取り外し */
{
if(p_top == d) {
p_top = d->next;
if(!p_top) p_tail = (PCELL far *)0;
else p_top->back = (PCELL far *)0;
}
else if(p_tail == d) {
p_tail = d->back;
if(!p_tail) p_top = (PCELL far *)0;
else p_tail->next = (PCELL far *)0;
}
else {
d->next->back = d->back;
d->back->next = d->next;
}
d->next = d->back = (PCELL far *)0;
}
static void cmtdelete1(PCELL far *d) /* 作業キュー取り外し */
{
if(work_top == d) {
work_top = d->next;
if(!work_top) work_tail = (PCELL far *)0;
else work_top->back = (PCELL far *)0;
}
else if(work_tail == d) {
work_tail = d->back;
if(!work_tail) work_top = (PCELL far *)0;
else work_tail->next = (PCELL far *)0;
}
else {
d->next->back = d->back;
d->back->next = d->next;
}
d->next = d->back = (PCELL far *)0;
}
static void cmtset(PCELL far *w,PCELL far *d) /* セル接続 */
{
w->next->back = d;
d->next = w->next;
d->back = w;
w->next = d;
}
PCELL far *cmtsepa(PCELL far *a) /* セパレータセル作成 */
{
PCELL far *pt;
char far *t;
int i;
if(sepamode) return((PCELL far *)-1);
pt = tbl_alloc(0);
if(!pt) {
errdisp1(memgeterror);
return((PCELL far *)-1);
}
pt->mode = NSEPA;
tbl_set(a);
i = a->p->fno;
tbl_set(pt);
pt->p->fno = i;
pt->grp = a;
_fstrcpy(pt->p->title,(char far *)spalate);
return(pt);
}
static int cmtsort1(PCELL far *a,int mode) /* 作業キューへの接続 */
{
PCELL far *w;
int i,j;
w = work_tail;
if(work_top && mode) {
for(;w;w=w->back) {
tbl_set(w);
j = w->p->id;
tbl_set(a);
i = a->p->id - j;
if(i < 0) continue;
if(i > 0) break;
return(0);
}
}
if(!work_top) {
work_top = work_tail = a;
a->next = a->back = (PCELL far *)0;
}
else if(!w) {
a->next = work_top;
work_top->back = a;
work_top = a;
a->back = (PCELL far *)0;
}
else if(!w->next) {
w->next = work_tail = a;
a->next = (PCELL far *)0;
a->back = w;
}
else {
a->next = w->next;
w->next = a;
a->back = w;
a->next->back = a;
}
return(1);
}
static int cmtsort11(PCELL far *a) /* コメントキューへの接続 */
{
PCELL far *w;
w = cmt_tail;
if(!cmt_top) {
cmt_top = cmt_tail = a;
a->next = a->back = (PCELL far *)0;
}
else if(!w->next) {
w->next = cmt_tail = a;
a->next = (PCELL far *)0;
a->back = w;
}
else {
a->next = w->next;
w->next = a;
a->back = w;
a->next->back = a;
}
return(1);
}
static void cmtsort12(PCELL far *a) /* フリーキューへの接続 */
{
PCELL far *w;
if(!(a->flag & FSAKUJYO)) {
a->flag |= FSAKUJYO;
sakujyono++;
}
w = free_tail;
if(!free_top) {
free_top = free_tail = a;
a->next = a->back = (PCELL far *)0;
}
else if(!w->next) {
w->next = free_tail = a;
a->next = (PCELL far *)0;
a->back = w;
}
else {
a->next = w->next;
w->next = a;
a->back = w;
a->next->back = a;
}
}
static void cmtsort2(PCELL far *a,int c) /* コメントツリーソート処理 */
{
PCELL far *pt;
int j,l;
tbl_set(a);
j = a->p->id;
pt=a->next;
cmtdelete1(a);
cmtsort11(a);
l = 0;
for(;pt;) {
tbl_set(pt);
if(pt->p->cid == j) {
l++;
cmtsort2(pt,c+1);
pt=work_top;
}
else pt = pt->next;
}
tbl_set(a);
a->p->cno = l;
a->p->cmt = c;
}
static PCELL far *
cmttitleset(PCELL far *a,int n) /* タイトルツリー文字列セット */
{
PCELL far *pt;
int l,c;
char *b,*buf,*w;
pt=a;
for(;n;n--) {
tbl_set(pt);
buf = (char *)malloc(81);
w = (char *)malloc(81);
if(buf && w) {
c=pt->p->cmt;
b = &cmt_tbl[c*2];
if(c == 20) strcpy(b,&treechar[9]);
else if(c < 20) {
if(n > 1) strcpy(b,&treechar[0]);
else strcpy(b,&treechar[3]);
}
strcpy(buf,cmt_tbl);
_fstrcpy((char far *)w,pt->p->title);
if(!(pt->flag & FCYCLE)) {
*(w+3) = 0;
strcat(buf,w);
if(titlemode)
strncat80(buf,(w+22));
else
strncat80(buf,(w+19));
}
else {
*(w+5) = 0;
strcat(buf,w);
if(titlemode)
strncat80(buf,(w+24));
else
strncat80(buf,(w+21));
}
str79set(buf);
/* _fstrcpy(pt->p->title2,pt->p->title); */
_fstrcpy(pt->p->title,(char far *)buf);
free(buf);
free(w);
}
else {
errdisp1(memgeterror);
if(buf) free(buf);
}
pt->flag |= FDISP;
l = pt->p->cno;
pt=pt->next;
if(l) {
if(c < 20) {
if(n > 1) strcpy(b,&treechar[6]);
else strcpy(b," ");
}
pt=cmttitleset(pt,l);
}
}
return(pt);
}
static void cmtsort(char mode) /* 昇順ソート処理 mode =NHP,=NFORUM,=NMAIL */
{
PCELL far *a = (PCELL far *)0;
PCELL far *w = (PCELL far *)0;
PCELL far *wk;
char mode1,mode2=0,*s,buf[81],buf1[81];
int i;
work_top=work_tail=(PCELL far *)0;
free_top=free_tail=(PCELL far *)0;
switch(mode) {
case NHP: mode1 = NHPHEAD; i = 1;break;
case NFORUM: mode1 = NMESHEAD; i = 1;break;
default: mode1 = NMAILHEAD; mode2 = NMWRITE; i = 0;break;
}
tbl_set(p_head);
_fstrcpy((char far *)buf,p_head->p->title);
if(s = jstrchr(buf,':')) *s = 0;
for(a = p_head->next;a->mode != NEND;a = w) {
w = a->next;
if(a->grp->mode == mode1) {
wk = a->grp;
tbl_set(wk);
_fstrcpy((char far *)buf1,wk->p->title);
if(s = jstrchr(buf1,':')) *s = 0;
if(strcmp(buf,buf1)) continue;
if(a->mode == NSEPA) {
cmtdelete(a);
cmtfree(a);
continue;
}
else {
if(a->mode != mode && a->mode != mode2) continue;
}
}
else continue;
if(p_head != a->grp) {
if(!(a->grp->flag & FSAKUJYO)) {
a->grp->flag |= FSAKUJYO;
sakujyono++;
}
a->grp = p_head;
}
cmtdelete(a);
a->flag |= FDISP;
if(!cmtsort1(a,i))
cmtsort12(a);
}
}
static void comentclr(void) /* コメント絞り込み解除 */
{
PCELL far *pt;
PCELL far *ppt;
PCELL far *a;
int i,x;
char buf[81],buf3[81],bufwork[81];
if(nifmode == NFCOMENTID) {
for(pt=p_top,i=1;pt;pt=pt->next,i++)
pt->count = i;
}
if(nifmode == NFCOMENT || nifmode == NFCOMENTID) {
xlocate();
kprintf("只今、コメントツリー解除処理中です。");
/* grh_disp("コメントツリー解除処理中",0); */
for(ppt=p_top;ppt->mode != NEND;ppt=ppt->next) {
/* if(!(ppt->count % 10)) grh_sub(ppt->count,p_tail->count); */
if(ppt->mode == NMESHEAD) {
p_head = ppt;
cmtsort(NFORUM);
for(i=0,pt=work_top;pt;pt=pt->next) {
/* if(!(pt->count % 10)) grh_sub(pt->count,p_tail->count); */
tbl_set(pt);
if(i && (i+1 != pt->p->id)) {
if((a = cmtsepa(p_head)) != (PCELL far *)-1) {
cmtset(pt->back,a);
}
}
tbl_set(pt);
i = pt->p->id;
if(pt->mode == NFORUM) {
/* _fstrcpy(pt->p->title,pt->p->title2); */
xxfseek(pt,pt->p->top);
xfgets(buf,81);
rtncut(buf);
xfgets(buf3,81);
rtncut(buf3);
memset(bufwork,0,81);
if(titlemode) {
if(pt->flag & FCYCLE) {
strncpy(bufwork,buf,5);
strncat(bufwork,&buf3[6],9);
strncat80(bufwork,&buf[11]);
}
else {
strncpy(bufwork,buf,3);
strncat(bufwork,&buf3[6],9);
strncat80(bufwork,&buf[9]);
}
}
else strcpy(bufwork,buf);
_fstrcpy(pt->p->title,(char far *)bufwork);
}
}
if(free_top) {
if((a = cmtsepa(p_head)) != (PCELL far *)-1)
cmtsort1(a,0);
if(work_top) {
work_tail->next = free_top;
free_top->back = work_tail;
}
else work_top = free_top;
work_tail = free_tail;
}
if(work_top) {
p_head->next->back = work_tail;
work_tail->next = p_head->next;
p_head->next = work_top;
work_top->back = p_head;
}
}
else if(ppt->mode == NHPHEAD) {
p_head = ppt;
cmtsort(NHP);
for(i=0,pt=work_top;pt;pt=pt->next) {
tbl_set(pt);
if(i && (i+1 != pt->p->id)) {
if((a = cmtsepa(p_head)) != (PCELL far *)-1) {
cmtset(pt->back,a);
}
}
tbl_set(pt);
i = pt->p->id;
}
if(free_top) {
if((a = cmtsepa(p_head)) != (PCELL far *)-1)
cmtsort1(a,0);
if(work_top) {
work_tail->next = free_top;
free_top->back = work_tail;
}
else work_top = free_top;
work_tail = free_tail;
}
if(work_top) {
p_head->next->back = work_tail;
work_tail->next = p_head->next;
p_head->next = work_top;
work_top->back = p_head;
}
}
}
}
for(pt=p_top,i=1;pt;pt=pt->next,i++) {
pt->count = i;
pt->flag &= ~FDISP;
}
/* grh_sub(1,1); */
p_head = p_top;
nifmode = NFNORMAL;
pfset();
}
static void totalset(int mode) /* 絞り込み時のタイトル絞り込み */
{
PCELL far *pt;
int j;
for(pt=p_top,j = 1;pt->mode != NEND;pt=pt->next) {
if(mode || pt->flag & FDISP) {
if(j == 1) p_head = pt;
pt->count = j++;
pt->flag &= ~FDISP;
}
else pt->count = 0;
}
pt->count = j;
}
static int subsearch(char *buf3,int mode) /* 検索サブ */
{
char buf[161],buf2[81],buf4[81],*b,*c;
int i,count = 0,e = 0;
_fstrcpy((char far *)buf,buf1[0]);
rtncut(buf);
for(i=0;;i++) {
if(!buf1[i] || e) break;
c = buf + strlen(buf);
_fstrcpy((char far *)buf2,buf1[i+1]);
if(strlen(buf2)) {
rtncut(buf2);
memcpy(buf4,buf2,81);
strncat(buf,buf2,160-strlen(buf));
}
else {
e = 1;
}
if(mode) fbuf1[i] = 0;
for(b = buf;b < c;) {
if(!(b = substrstr(b,buf3)) || b >= c) break;
b += rtnk;
count++;
if(mode) fbuf1[i] = 1;
}
memcpy(buf,buf4,81);
}
return(count);
}
static int shsub(char *buf3) /* 検索文字列入力 */
{
xlocate();
kprintf("検索文字列を入力 = ");
memset(buf3,0,43);
buf3[0] = 40;
strcpy(&buf3[2],kensakumoji);
cgetsx(buf3,0);
xlocate();
if(!buf3[2] || buf3[2] == 0x1b) {
return(0);
}
rtncut(&buf3[2]);
strcpy(kensakumoji,&buf3[2]);
return(1);
}
static int search(int mode) /* 検索 */
{
PCELL far *pt;
char buf[81],buf3[43];
int count = 0,mcount = 0,andormode = 0,i;
xhpread(MAXPOINT);
if(!mode && nifmode == NFSEARCH) {
if(!yesnocheck("AND検索を行いますか")) andormode = 1;
}
if(!shsub(buf3)) return(0);
if(mode) {
kprintf(srcmsg);
count = subsearch(&buf3[2],1);
if(count) {
sprintf(buf,"「%s」が%d件あります",&buf3[2],count);
errdisp1(buf);
return(1);
}
sprintf(buf,"「%s」が見つかりません",&buf3[2]);
errdisp1(buf);
return(0);
}
if(nifmode == NFCOMENT || nifmode == NFCOMENTID) {
comentclr();
}
xlocate();
if(!andormode) {
grh_dispx("AND検索処理中",1);
for(pt=p_head;pt->mode != NEND;pt=pt->next) {
if(pt->count) {
tbl_set(pt);
if(pt->p->top == pt->p->tail)
continue;
/* xlocate();
sprintf(buf,"只今、%d/%dタイトル目を検索中です。",pt->count,p_tail->count-1);
kprintf(buf); */
bunget(pt,1);
count = subsearch(&buf3[2],0);
bunbuffree();
tbl_set(pt);
if(count) {
pt->flag |= FDISP;
pt->p->cmt = count;
mcount++;
}
else {
pt->flag &= ~FDISP;
pt->p->cmt = 0;
}
}
if(keycheck() && getch() == 0x1b) break;
if(!(pt->count % 10)) grh_sub(pt->count,p_tail->count-1);
}
}
else {
grh_dispx("OR検索処理中",1);
for(i=1,pt=p_top;pt->mode != NEND;pt=pt->next) {
tbl_set(pt);
if(pt->p->top != pt->p->tail) {
/* xlocate();
sprintf(buf,"只今、%d/%dタイトル目を検索中です。",i,p-1);
kprintf(buf); */
bunget(pt,1);
count = subsearch(&buf3[2],0);
bunbuffree();
tbl_set(pt);
if(count) {
pt->flag |= FDISP;
pt->p->cmt += count;
mcount++;
}
else {
if(pt->count) {
pt->flag |= FDISP;
mcount++;
}
else {
pt->flag &= ~FDISP;
pt->p->cmt = 0;
}
}
}
if(keycheck() && getch() == 0x1b) break;
if(!(i % 10)) grh_sub(i++,p-1);
}
}
grh_sub(1,1);
if(mcount) {
totalset(0);
nifmode = NFSEARCH;
pfset();
sprintf(buf,"%dタイトルで発見",mcount);
errdisp1(buf);
return(1);
}
sprintf(buf,"「%s」が見つかりません",&buf3[2]);
errdisp1(buf);
return(0);
}
static PCELL far *coment(PCELL far *tcu,int mode) /* コメント */
{
PCELL far *pt;
int i;
char *s,buf[81],buf1[81];
if(nifmode != NFNORMAL) {
comentclr();
return(tcu);
}
if ( !mode && (tcu->grp->mode != NMESHEAD /* フォーラム会議室タイトル */
&& tcu->grp->mode != NHPHEAD /* HPタイトル */
&& tcu->grp->mode != NMAILHEAD /* 電子メールタイトル */
|| tcu->mode == NHPWRITE /* HPの送信 */
|| tcu->mode == NMWRITE /* 電子メールの送信 */
|| tcu->mode == NFWRITE)) { /* フォーラムの送信 */
errdisp1(notcomenterror);
return((PCELL far *)0);
}
xlocate();
kprintf("只今、コメントツリー作成処理中です。");
xhpread(MAXPOINT);
for(;tcu->mode == NSEPA;tcu = tcu->back) {
;
}
for(pt = p_top;pt->mode != NEND;pt=pt->next) {
if(pt->mode == NMAILHEAD) {
p_head = pt;
cmtsort(NMAIL);
if(free_top) {
if(work_top) {
work_tail->next = free_top;
free_top->back = work_tail;
}
else work_top = free_top;
work_tail = free_tail;
}
if(work_top) {
p_head->next->back = work_tail;
work_tail->next = p_head->next;
p_head->next = work_top;
work_top->back = p_head;
pt = work_tail;
}
p_head->flag |= FDISP;
}
}
for(pt = p_top;pt->mode != NEND;pt=pt->next) {
if(pt->mode == NHPHEAD) {
p_head = pt;
cmtsort(NHP);
if(free_top) {
if(work_top) {
work_tail->next = free_top;
free_top->back = work_tail;
}
else work_top = free_top;
work_tail = free_tail;
}
if(work_top) {
p_head->next->back = work_tail;
work_tail->next = p_head->next;
p_head->next = work_top;
work_top->back = p_head;
pt = work_tail;
}
p_head->flag |= FDISP;
}
}
for(pt = p_top;pt->mode != NEND;pt=pt->next) {
if(pt->mode == NMESHEAD) {
p_head = pt;
cmtsort(NFORUM);
cmt_top=cmt_tail=(PCELL far *)0;
for(i=0;work_top;i++)
cmtsort2(work_top,0);
memset(cmt_tbl,0,41);
if(cmt_top) {
cmttitleset(cmt_top,i);
if(free_top) {
for(pt=free_top;pt;pt=pt->next)
pt->flag |= FDISP;
cmt_tail->next = free_top;
free_top->back = cmt_tail;
cmt_tail = free_tail;
}
p_head->next->back = cmt_tail;
cmt_tail->next = p_head->next;
p_head->next = cmt_top;
cmt_top->back = p_head;
pt = cmt_tail;
}
p_head->flag |= FDISP;
}
}
if((startmode & 0x0e) == 6) totalset(1);
else totalset(0);
nifmode = NFCOMENT;
pfset();
if(!tcu) {
if(p_tail->count == 1)
comentclr();
return(p_head);
}
if(p_tail->count == 1) {
comentclr();
errdisp1("コメント機能の対象となるデータがありません");
return((PCELL far *)0);
}
if(!tcu->count) {
for(tcu=tcu->back;tcu && tcu->count != 1;tcu=tcu->back) {
if(tcu->count)
break;
}
if(!tcu) return(p_head);
}
return(tcu);
}
static PCELL far *comentid(PCELL far *tcu) /* コメント+ID */
{
PCELL far *pt;
PCELL far *ppt;
int i,savemode;
tbl_set(tcu);
if(!tcu->p->nifid[0]) {
errdisp1(notcomenterror);
return((PCELL far *)0);
}
xhpread(MAXPOINT);
memset(nifid,0,9);
tbl_set(tcu);
_fmemcpy(nifid,tcu->p->nifid,8);
if(nifmode != NFNORMAL)
comentclr();
savemode = startmode;
startmode = 6;
coment(0,1);
startmode = savemode;
for(pt=p_top;pt->mode != NEND;pt=pt->next) {
if(!pt->count) continue;
tbl_set(pt);
if(pt->mode == NFORUM && !pt->p->cmt) {
for(i=0,ppt = pt;ppt->mode == NFORUM;) {
tbl_set(ppt);
if(!_fmemcmp(nifid,ppt->p->nifid,8)) {
i = 1;
break;
}
ppt=ppt->next;
tbl_set(ppt);
if(!ppt->p->cmt) break;
}
if(i) {
for(ppt = pt;ppt->mode == NFORUM;) {
tbl_set(ppt);
ppt->flag |= FDISP;
ppt=ppt->next;
tbl_set(ppt);
if(!ppt->p->cmt) break;
}
}
pt = ppt->back;
continue;
}
if(!_fmemcmp(nifid,pt->p->nifid,8)) {
pt->flag |= FDISP;
}
}
totalset(0);
nifmode = NFCOMENTID;
pfset();
return(tcu);
}
static int sentaku(PCELL far *tcu) /* 選択 */
{
if(tcu->mode == NEND)
return(0);
/* if(tcu->mode == NSEPA) */
tbl_set(tcu);
if(tcu->p->top == tcu->p->tail)
return(1);
if(tcu->flag & FSENTAKU) {
tcu->flag &= ~FSENTAKU;
sentakuno--;
return(1);
}
tcu->flag |= FSENTAKU;
sentakuno++;
return(1);
}
static int idset(PCELL far *tcu) /* ID絞り込み */
{
PCELL far *pt;
tbl_set(tcu);
if(!tcu->p->nifid[0]) {
errdisp1(notiderror);
return(0);
}
xhpread(MAXPOINT);
memset(nifid,0,9);
tbl_set(tcu);
_fmemcpy((char far *)nifid,tcu->p->nifid,8);
if(nifmode == NFCOMENT || nifmode == NFCOMENTID)
comentclr();
for(pt=p_head;pt->mode != NEND;pt=pt->next) {
if(pt->count) {
tbl_set(pt);
pt->flag &= ~FDISP;
if(!pt->p->nifid[0]) continue;
if(_fmemcmp(pt->p->nifid,nifid,8)) continue;
pt->flag |= FDISP;
}
}
totalset(0);
nifmode = NFID;
pfset();
return(1);
}
static int tagset(PCELL far *tcu) /* タグ設定 */
{
tbl_set(tcu);
if(tcu->mode == NEND || (tcu->p->top == tcu->p->tail)) {
errdisp1(tagseterror);
return(0);
}
if(tcu->flag & FTAG) {
tcu->flag &= ~FTAG;
tagno--;
return(1);
}
tcu->flag |= FTAG;
tagno++;
return(1);
}
static PCELL far *tagmae(PCELL far *tcu) /* タグ前ジャンプ */
{
PCELL far *pt;
if(tagno) {
for(pt = tcu->back;pt;pt=pt->back) {
if(!pt->count) continue;
if(pt->flag & FTAG) return(pt);
}
}
errdisp1(tagnoterror);
return((PCELL far *)0);
}
static PCELL far *tagato(PCELL far *tcu) /* タグ次ジャンプ */
{
PCELL far *pt;
if(tagno) {
for(pt = tcu->next;pt && pt->mode != NEND;pt=pt->next) {
if(!pt->count) continue;
if(pt->flag & FTAG) return(pt);
}
}
errdisp1(tagnoterror);
return((PCELL far *)0);
}
static PCELL far *shmae(PCELL far *tcu,int mode) /* 前検索ジャンプ */
{
PCELL far *pt;
char buf[81],buf3[43];
if(!shsub(buf3)) return((PCELL far *)0);
bunbuffree();
kprintf(srcmsg);
for(pt = tcu->back;pt;pt=pt->back) {
if(!pt->count) continue;
tbl_set(pt);
_fstrcpy((char far *)buf,pt->p->title);
if(substrstr(buf,&buf3[2]))
return(pt);
if(!mode) {
bunget(pt,1);
if(subsearch(&buf3[2],0)) {
bunbuffree();
return(pt);
}
bunbuffree();
}
}
sprintf(buf,"「%s」が見つかりません",&buf3[2]);
errdisp1(buf);
return((PCELL far *)0);
}
static PCELL far *shato(PCELL far *tcu,int mode) /* 次検索ジャンプ */
{
PCELL far *pt;
char buf[81],buf3[43];
xhpread(MAXPOINT);
bunbuffree();
if(!shsub(buf3)) return((PCELL far *)0);
kprintf(srcmsg);
for(pt = tcu->next;pt && pt->mode != NEND;pt=pt->next) {
if(!pt->count) continue;
tbl_set(pt);
_fstrcpy((char far *)buf,pt->p->title);
if(substrstr(buf,&buf3[2]))
return(pt);
if(!mode) {
bunget(pt,1);
if(subsearch(&buf3[2],0)) {
bunbuffree();
return(pt);
}
bunbuffree();
}
}
sprintf(buf,"「%s」が見つかりません",&buf3[2]);
errdisp1(buf);
return((PCELL far *)0);
}
static void jumpmodechg(void) /* ジャンプモード切替え処理 */
{
if(++nextmode > 2) nextmode = 0;
}
static void title3disp(PCELL far *tcu) /* タイトル画面の一画面分を求める */
{
PCELL far *pt;
int k;
xhpread(tcu->count+line);
ttop = p_head;
ggtop = ttop;
while(1) {
for(k = 3,pt = ggtop;pt && k <= line-2;pt=pt->next) {
if(!pt->count) continue;
k++;
}
if(pt) ggtail = pt->back;
else ggtail = p_tail;
if(ggtop->count <= tcu->count && ggtail->count >= tcu->count)
return;
for(ggtop = ggtail->next;!ggtop->count;ggtop=ggtop->next);
}
}
char cnvpfkey(int a) /* キー変換 */
{
if(keytbl[a])
return(keytbl[a]);
return((char)0);
}
static PCELL far *uptcu0(PCELL far *tcu) /* タイトル一つ次へ */
{
xhpread(tcu->count+line);
if(tcu->mode != NEND) {
for(tcu=tcu->next;tcu->mode != NEND;tcu=tcu->next) {
if(tcu->count)
break;
xhpread(tcu->count+line);
}
}
return(tcu);
}
static PCELL far *uptcu(PCELL far *tcu) /* タイトル一つ次へ */
{
if(tcu->mode != NEND) {
for(tcu=tcu->next;tcu && tcu->mode != NEND;tcu=tcu->next) {
if(tcu->count)
break;
}
if(!tcu) return(p_tail);
}
return(tcu);
}
static PCELL far *downtcu(PCELL far *tcu) /* タイトル一つ前へ */
{
if(tcu->count != 1) {
for(tcu=tcu->back;tcu->count != 1;tcu=tcu->back) {
if(tcu->count)
break;
}
}
return(tcu);
}
static PCELL far *muptcu(PCELL far *tcu,int count) /* タイトル複数次へ */
{
for(;count;count--)
tcu = uptcu(tcu);
return(tcu);
}
static PCELL far *mdowntcu(PCELL far *tcu,int count) /* タイトル複数前へ */
{
for(;count;count--)
tcu = downtcu(tcu);
return(tcu);
}
static PCELL far *nextjump(PCELL far *tcu,int count) /* ジャンプ処理 */
{
PCELL far *pt;
xhpread(tcu->count+count+line);
pt = muptcu(tcu,count);
if(pt->mode == NEND) return(downtcu(pt));
return(pt);
}
static int kidokuset(PCELL far *tcu) /* 既読セット処理 */
{
PCELL far *pt;
if(!yesnocheck("ここまでを既読としますか")) return(0);
for(pt = tcu;pt;pt = pt->back) {
if(!pt->count) continue;
if(pt->mode < NHPHEAD)
pt->flag |= FYOMI;
}
return(1);
}
static int kidokucancel(PCELL far *tcu) /* 既読キャンセル処理 */
{
PCELL far *pt;
if(!yesnocheck("以降の既読を取消しますか")) return(0);
for(pt = tcu;pt && pt->mode != NEND;pt = pt->next) {
if(!pt->count) continue;
if(pt->mode < NHPHEAD)
pt->flag &= ~FYOMI;
}
return(1);
}
static void bundispsub(int po) /* 内容一行表示 */
{
char buf[81];
if(!fbuf1[po]) iro(INAIYOU);
else iro(IKENSAKU);
bunmode = 1;
clr2();
_fstrcpy((char far *)buf,buf1[po]);
print(buf);
bunmode = 0;
}
static PCELL far *autodisp(PCELL far *tcu) /* 自動表示 */
{
PCELL far *pt;
int gtop,gtail,btail,k,rcode,savetime;
char a,buf[81],savenifmode;
int dispflag = 0;
if(tcu->mode == NEND)
return((PCELL far *)0);
xhpread(MAXPOINT);
savenifmode = nifmode;
for(k=0;k < MAXLINE;k++) fbuf1[k]=0;
for(pt=tcu;pt->mode != NEND;pt=pt->next) {
if(!pt->count) continue;
if(pt->flag & FSAKUJYO) continue;
if(pt->mode == NSEPA) continue;
if(nextmode && pt->mode >= NHPHEAD) continue;
if(nextmode > 1 && (pt->flag & FYOMI)) continue;
if(!(k = bunget(pt,1))) continue;
savetime = 0;
gtop = 1; btail = k-1;
dispflag = 0;
for(rcode=0;rcode != 2;) {
pfset();
pfdisp(4);
for(k = 0;k < line-4;k++) {
if(gtop+k > btail) break;
loc(1,k+3);
bundispsub(gtop+k-1);
}
gtail = gtop+k-1;
if(!savetime || !pagemode || pagemode == 3)
autodisptime = autodisptime2 * k;
else if(pagemode == 1)
autodisptime = autodisptime2 * ((k+1)/2);
else
autodisptime = autodisptime2;
autodisptime = (autodisptime+9)/10;
savetime = 1;
for(;k < line-4;k++) {
loc(1,k+3);clr1(INAIYOU);
}
for(rcode=0;!rcode;) {
if(gtail >= btail) {
if(tagmode && pt->mode < NHPHEAD)
pt->flag |= FYOMI;
}
nifmode=NFAUTO1;
if(gtop != 1) {
nstatus(1,pt,pt->count,p_tail->count,gtail,btail);
if(pt->mode < NHPHEAD && !dispflag) {
loc(1,2);
memset(buf,0,81);
_fstrcpy((char far *)buf,buf1[0]);
rtncut(buf);
strncat80(buf,space);
switch(pt->flag & ~(FTAG+FYOMI+FCYCLE)) {
case FSENTAKU: iro(IRSENTAKU); break;
case FSAKUJYO: iro(IRSAKUJYO); break;
case FSENTAKU+FSAKUJYO: iro(IRGATTAI); break;
default: if(pt->flag & FYOMI) iro(IRYOMI);
else iro(IMODE);
break;
}
bunmode = 1;
print(buf);
bunmode = 0;
deforutoiro();
dispflag = 1;
}
}
else {
savepno = -1;
nstatus(1,pt,pt->count,p_tail->count,gtail,btail);
dispflag = 0;
}
time(lsavetime);
a = keyget2(2);
switch(a) {
case 0x1b: /* ESCキー */
case 0x0d: /* 改行キー */
bunbuffree();
goto autodisp_end;
case 0x20: /* 空白キー */
nifmode=NFAUTO2;
nstatus(1,pt,pt->count,p_tail->count,gtail,btail);
for(rcode=0;!rcode;) {
a = keyget2(1);
switch(a) {
case 0x1b: /* ESCキー */
case 0x0d: /* 改行キー */
bunbuffree();
goto autodisp_end;
case 0x20: /* 空白キー */
rcode=1;
break;
}
}
case 0: /* タイムアウト処理 */
if(gtail >= btail) {
autodisptime = autodisptime2*5;
autodisptime = (autodisptime+9)/10;
savetime = 1;
time(lsavetime);
for(;keyget2(2);)
;
if(tagmode && pt->mode < NHPHEAD)
pt->flag |= FYOMI;
rcode = 2;
break;
}
if(pagemode <= 1 || pagemode == 3) {
if(pagemode != 1) gtop += line-4;
else gtop += (line-4)/2;
if(gtop > btail) gtop = btail;
}
else {
gtop++;
if(gtail < btail) gtail++;
sclup();
if(gtop+line-5 <= btail) {
loc(1,line-2);
bundispsub(gtop+line-6);
}
}
rcode = 1;
break;
}
}
}
bunbuffree();
}
autodisp_end:
nifmode = savenifmode;
return(pt);
}
static int bundisp(PCELL far *tcu) /* 内容表示 */
{
char a,buf[81];
int k,rcode,btop,btail,gtop,gtail;
PCELL far *pt;
int dispflag=0;
tmode = 0;
for(k=0;k < MAXLINE;k++) fbuf1[k]=0;
if(!(k = bunget(tcu,1))) return(0);
gtop = btop = 1; btail = k-1;
/* if(mode) {
gtop = btail - (line-5);
if(gtop < 1) {
gtop = 1;
}
} */
while(1) {
display:
pfset();
savepno = -1;
dispflag = 0;
display1:
topdisp();
pfdisp(0);
for(k = 0;k < line-4;k++) {
if(gtop+k > btail) break;
loc(1,k+3);
bundispsub(gtop+k-1);
}
gtail = gtop+k-1;
for(;k < line-4;k++) {
loc(1,k+3);clr1(INAIYOU);
}
keyread:
if(gtail >= btail) {
if(tagmode && tcu->mode < NHPHEAD) {
tcu->flag |= FYOMI;
dispflag = 0;
}
}
if(gtop != btop) {
nstatus(1,tcu,tcu->count,p_tail->count,gtail,btail);
if(tcu->mode < NHPHEAD && !dispflag) {
loc(1,2);
memset(buf,0,81);
_fstrcpy((char far *)buf,buf1[0]);
rtncut(buf);
strncat80(buf,space);
switch(tcu->flag & ~(FTAG+FYOMI+FCYCLE)) {
case FSENTAKU: iro(IRSENTAKU); break;
case FSAKUJYO: iro(IRSAKUJYO); break;
case FSENTAKU+FSAKUJYO: iro(IRGATTAI); break;
default: if(tcu->flag & FYOMI) iro(IRYOMI);
else iro(IMODE);
break;
}
bunmode = 1;
print(buf);
bunmode = 0;
deforutoiro();
dispflag = 1;
}
}
else {
savepno = -1;
nstatus(1,tcu,tcu->count,p_tail->count,gtail,btail);
dispflag = 0;
}
time(lsavetime);
a = keyget2(1);
a = cnvpfkey(a);
switch(a) {
case UEYA: /* ↑キー処理 */
if(gtop <= btop) {
goto keyread;
}
gtop--;
if(gtop+line-5 < gtail) gtail--;
scldown();
loc(1,3);
bundispsub(gtop-1);
goto keyread;
case SITAYA: /* ↓キー処理 */
if(gtail >= btail) {
goto keyread;
}
gtop++;
if(gtail < btail) gtail++;
sclup();
if(gtop+line-5 <= btail) {
loc(1,line-2);
bundispsub(gtop+line-6);
}
goto keyread;
case HIDARIYA: /* ←キー処理 */
if(gtop == btop) {
if(tcu == ttop && topendmode) {
errdisp1(toperror);
goto keyread;
}
rcode = -1;
break;
}
if(pagemode != 1) gtop -= line-4;
else gtop -= (line-4)/2;
if(gtop < btop) gtop = btop;
goto display;
case MIGIYA: /* →キー処理 */
if(gtail >= btail) {
if(uptcu(tcu) == ttail && topendmode) {
errdisp1(enderror);
goto keyread;
}
rcode = 1;
break;
}
if(pagemode != 1) gtop += line-4;
else gtop += (line-4)/2;
if(gtop > btail) gtop = btail;
goto display;
case SENTAKU: /* 選択キー処理 */
sentaku(tcu);
savepno = -1;
dispflag = 0;
goto keyread;
case KAIGYO: /* 終了処理 */
case ESC:
case PF1:
rcode = 0;
break;
case PF2: /* 先頭行表示処理 */
if(gtop == btop) {
goto keyread;
}
gtop = btop;
goto display;
case PF3: /* 最終行表示処理 */
if(gtail >= btail) {
goto keyread;
}
gtop = btail-line+5;
if(gtop < 1) gtop = 1;
goto display;
case PF4: /* ヘルプ処理 */
help(1);
goto display;
case PF5: /* 切り出し処理 */
if(!kiridasi(tcu)) goto display1;
bunget(tcu,1);
goto display;
case PF6: /* 削除処理 */
if(!sakujyo(tcu)) goto keyread;
goto display;
case PF7: /* コピー処理 */
if(!fukusya(tcu)) goto display1;
bunget(tcu,1);
goto display;
case PF8: /* 検索処理 */
search(1);
goto display;
case PF9: /* ID処理 */
if(idset(tcu)) {
title3disp(tcu);
savepno = -1;
topdisp();
pfdisp(0);
}
goto display;
case PF10: /* コメント処理 */
if(coment(tcu,0)) {
title3disp(tcu);
savepno = -1;
topdisp();
pfdisp(0);
}
goto display;
case S_PF1: /* DOS呼び出し処理 */
k = oscall();
if(k == -1) {
rcode = -4; break;
}
if(k == -2) {
rcode = -5; break;
}
goto display;
case S_PF2: /* 前項処理 */
rcode = -1; break;
case S_PF3: /* 次項処理 */
rcode = 1; break;
case S_PF5: /* 選択取り消し処理 */
if(!torikesi())
goto keyread;
savepno = -1;
dispflag = 0;
goto keyread;
case S_PF6: /* 削除取り消し処理 */
if(!sakutorikesi())
goto keyread;
savepno = -1;
dispflag = 0;
goto keyread;
case S_PF7: /* タグセット処理 */
if(!tagset(tcu))
goto keyread;
savepno = -1;
dispflag = 0;
goto keyread;
case S_PF8: /* タグ前ジャンプ処理 */
if(!(pt=tagmae(tcu)))
goto keyread;
pt->flag |= FJUMP;
rcode = -2; break;
case S_PF9: /* タグ後ろジャンプ処理 */
if(!(pt=tagato(tcu)))
goto keyread;
pt->flag |= FJUMP;
rcode = 2; break;
case S_PF10: /* 発言処理 */
if(!hatugen(tcu,0)) goto display1;
goto display;
case C_PF2: /* タイトル出力処理 */
titleout();
goto display;
case C_PF3: /* 前検索ジャンプ処理 */
if(!(pt=shmae(tcu,0))) {
bunget(tcu,1);
goto display;
}
pt->flag |= FJUMP;
rcode = -2; break;
case C_PF4: /* 後ろ検索ジャンプ処理 */
if(!(pt=shato(tcu,0))) {
bunget(tcu,1);
goto display;
}
pt->flag |= FJUMP;
rcode = 2; break;
case C_PF5: /* 印刷 */
if(!printsub(tcu)) goto display1;
bunget(tcu,1);
goto display;
case C_PF8: /* 行数切り換え処理 */
chgline(tcu);
goto display;
case C_PF9: /* 利用者コマンド処理 */
k=usertouroku(tcu,gtop);
if(k == 1) {
bunget(tcu,1);
}
if(k == -1) {
rcode = -4; break;
}
if(k == -2) {
rcode = -5; break;
}
goto display;
case C_PF10: /* 自動表示処理 */
bunbuffree();
pt = autodisp(tcu);
if(pt == tcu) {
bunget(tcu,1);
goto display;
}
pt->flag |= FJUMP;
rcode = 2; break;
case SC_PF2: /* ジャンプ10処理 */
if((pt=nextjump(tcu,9)) == tcu)
goto keyread;
pt->flag |= FJUMP;
rcode = 2; break;
case SC_PF3: /* ジャンプ20処理 */
if((pt=nextjump(tcu,19)) == tcu)
goto keyread;
pt->flag |= FJUMP;
rcode = 2; break;
case SC_PF4: /* ジャンプ50処理 */
if((pt=nextjump(tcu,49)) == tcu)
goto keyread;
pt->flag |= FJUMP;
rcode = 2; break;
case SC_PF5: /* 既読セット処理 */
if(!kidokuset(tcu))
goto keyread;
goto display;
case SC_PF6: /* 既読キャンセル処理 */
if(!kidokucancel(tcu))
goto keyread;
goto display;
case SC_PF7: /* ジャンプモード切替え処理 */
jumpmodechg();
goto keyread;
case SC_PF9: /* コメント+ID処理 */
if(comentid(tcu)) {
title3disp(tcu);
savepno = -1;
topdisp();
pfdisp(0);
}
goto display;
case SC_PF10: /* 発言2処理 */
if(!hatugen(tcu,1)) goto display1;
goto display;
default: /* 無効キー処理 */
errdisp1(keyerror);
goto keyread;
}
break;
}
bunbuffree();
return(rcode);
}
static long wait2time(void) /* ウェイト処理1 */
{
long j=0;
j += 1 * 123;
return(j);
}
static long timework;
static void waittime(int time) /* ウェイト処理2 */
{
int i;
for(i = 0; i < time; i++)
timework = wait2time();
}
static void typedisp(PCELL far *tcu) /* TYPE */
{
int a;
long nl;
allclr();
restorecon(1);
setline(0);
tbl_set(tcu);
xxfseek(tcu,tcu->p->top);
nl = tcu->p->tail;
while(xftell() < nl || !nl) {
if((a = xfgetc()) < 0) break;
putchar(a);
if(kbhit()) {
if(getch() == 0x1b) {
printf("\n");
break;
}
}
waittime(typespeed*typespeed);
}
locate(1,line-1);clr();
kprintf(etckeymsg);
keyget();
allclr();
setcon(1);
setline(line);
}
static int logproc=0; /* ログ整理済フラグ */
static void logedit(int mode) /* ログ整理処理 */
{
PCELL far *pt;
int i;
char buf[81];
xhpread(MAXPOINT);
if(logproc) { /* ログ整理済? */
if(logproc == 1) {
if(!yesnocheck("ログ整理(大分類)済です。続行しますか")) return;
}
else {
if(!yesnocheck("ログ整理(詳細分類)済です。続行しますか")) return;
}
}
if(!mode) {
if(!yesnocheck("ログ整理(大分類)を行いますか")) return;
}
else {
if(!yesnocheck("ログ整理(詳細分類)を行いますか")) return;
}
if(tagmode == 2) {
for(pt=p_tail,i=0;pt;pt=pt->back) {
if(pt->mode < NHPHEAD) {
if(pt->flag & FYOMI) i = 1;
else {
if(i) pt->flag |= FYOMI;
}
}
}
}
memset(logforum,0,9);
memset(loghpid,0,9);
memset(logmes,0,3);
memset(loglib,0,3);
memset(logniftyid,0,9);
dateget();
if(!mode) {
grh_dispx("ログ整理(大分類)処理中",1);
}
else {
grh_dispx("ログ整理(詳細分類)処理中",1);
}
for(pt=p_top,i=1; pt->mode != NEND;pt=pt->next) {
if(!pt->count) continue;
if(pt->flag & FSAKUJYO) continue;
/* xlocate();
sprintf(buf,"只今、%d/%dタイトル目を処理中です。",i,p_tail->count-sakujyono-1);
kprintf(buf); */
if(logedit1(pt,0,mode));
if(keycheck() && getch() == 0x1b) break;
grh_sub(i++,p_tail->count-sakujyono-1);
}
grh_sub(1,1);
logproc = mode+1;
logclose(1);
}
static void logeditx(char mode) /* ログ整理処理(バッチ処理用) */
{
PCELL far *pt;
int i;
char *s;
if(!mode) s = "大";
else s = "詳細";
printf("%sファイルのログ整理(%s分類)出力中です(ESCキーで中断)。\n",gfilename,s);
memset(logforum,0,9);
memset(loghpid,0,9);
memset(logmes,0,3);
memset(loglib,0,3);
memset(logniftyid,0,9);
dateget();
for(pt=p_top,i=1; pt->mode != NEND;pt=pt->next,i++) {
if(logedit1(pt,1,(int)mode));
if(keycheck() && getch() == 0x1b) break;
}
logclose(1);
}
static int endcheck(void) /* 終了処理 */
{
char filename1[129],filename2[129];
PCELL far *pt;
PCELL far *pw;
char *a,buf[81];
FILE *fd1;
int j,x,endf=1,sno;
long nl,top,tail,lno,w,w2;
char cmd[256],dir[231];
if(nifmode != NFNORMAL)
comentclr();
if(tagmode == 2) {
for(pt=p_tail,j=0;pt;pt=pt->back) {
if(pt->mode < NHPHEAD) {
if(pt->flag & FYOMI) j = 1;
else {
if(j) pt->flag |= FYOMI;
}
}
}
}
if(!(foutmode & F_MEMERR) && (sakujyono || foutmode)) {
if(!sakujyomode) {
sprintf(buf,"元のログファイルを修正してもいいですか");
if(!yesnocheck(buf)) goto endck_rtn;
}
xhpread(MAXPOINT);
if(startmode >= 8) fno = 1;
sno = sakujyono;
for(;fno <= maxfno;) {
endf = 1;
midokuno = 0;
if(maxfno > 1)
_fstrcpy((char far *)filename,file[fno-1]);
if(!(midokumode & 2) && (tagmode >= 3))
if(nifoutopen()) goto endck_rtn;
strcpy(filename1,filename);
if(!(a = jstrrchr(filename1,'.'))) {
strcpy(filename2,filename);
}
else {
*a = 0;
strcpy(filename2,filename1);
}
strcat(filename1,".$$$");
strcat(filename2,".");
strcat(filename2,savsafix);
remove(filename1);
if(!(fd1 = xxfopen(filename1,"at"))) {
endck_rtn0:
if(!(midokumode & 2) && (tagmode >= 3))
nifoutclose(1);
goto endck_rtn;
}
grh_dispx("ログファイル修正中",0);
xlocate();
for(pt=p_top,j=0,x=p_tail->count-sno,lno=w=1;pt;pt=pt->next) {
tbl_set(pt);
if(pt->flag & FSAKUJYO) {
if(w) lno += pt->p->lineno - w;
w = 0;
pt->flag &= ~FSAKUJYO;
sno--;
continue;
}
if(!(midokumode & 2) && (tagmode >= 3)) {
if(pt->mode != NSEPA) {
w2 = pt->p->lineno;
if(w) lno += w2 - w;
w = w2;
pt->p->lineno = lno;
top = pt->p->top;
tail = pt->p->tail;
pt->p->top = ftell(fd1);
pt->p->tail = tail - top + pt->p->top;
if(nifoutput(pt)) {
nifoutclose(1);
goto endck_rtn;
}
tbl_set(pt);
pt->p->top = top;
pt->p->tail = tail;
}
}
xlocate();
if(pt->mode == NEND) break;
/* sprintf(buf,"只今、%d/%dタイトル目を出力中です。",++j,x-1);
kprintf(buf); */
if(!(j++ % 10)) grh_sub(j,x-1);
if(pt->p->top == pt->p->tail) {
/* if(pt->mode == NSEPA) continue;
_fstrcpy((char far *)buf,pt->p->title);
strcat(buf,"\n");
if(fputsub(buf,fd1,filename1)) {
remove(filename1);
goto endck_rtn0;
} */
continue;
}
else {
xxfseek(pt,pt->p->top);
nl = pt->p->tail;
if(xftell() == nl) continue;
while(xftell() < nl || !nl) {
if(!xfgets(buf,81)) break;
if(fputsub(buf,fd1,filename1)) {
remove(filename1);
goto endck_rtn0;
}
}
}
if(pt->mode < NHPHEAD) {
if(endf && pt->flag & FYOMI)
midokuno++;
else
endf = 0;
}
}
grh_sub(1,1);
if(!(midokumode & 2) && (tagmode >= 3))
nifoutclose(1);
if(endf) midokuno = 0 - midokuno;
fclose(fd1);
xfclose();
if(!editmode) {
if(!*bakdir) {
remove(filename2);
rename(filename,filename2);
rename(filename1,filename);
}
else {
strcpy(dir,bakdir);
if(!(a = jstrrchr(filename,'\\'))
&& !(a = jstrrchr(filename,':')))
a = filename;
else a++;
strncat(dir,a,230);
sprintf(cmd, "COPY %s %s > NUL", filename, dir);
system(cmd);
ems_lno = -1;
/* remove(filename);
rename(filename1,filename); */
sprintf(cmd, "COPY %s %s > NUL", filename1, filename);
system(cmd);
remove(filename1);
}
}
else {
remove(filename);
rename(filename1,filename);
}
if(startmode < 8) break;
fno++;
}
return(1);
}
endck_rtn:
midokuno = 0;
switch(tagmode) {
case 0: break;
case 1:
case 2:
for(pt = p_top;pt; pt = pt->next) {
if(pt->mode >= NHPHEAD) continue;
if(!(pt->flag & FYOMI)) {
endf = 0;
break;
}
midokuno++;
}
if(endf) midokuno = 0 - midokuno;
break;
default:
if((midokumode & 2)) break;
xhpread(MAXPOINT);
if(nifoutopen()) break;
for(pt = p_top; pt; pt = pt->next) {
if(pt->mode == NSEPA) continue;
if(nifoutput(pt)) break;
}
nifoutclose(1);
}
return(0);
}
static void title1disp(PCELL far *tcu,int mode) /* タイトルリバース表示 */
{
char buf[81],mode1;
loc(1,tcu->count - ggtop->count+3);
memset(buf,0,81);
sprintf(buf," ");
tbl_set(tcu);
_fstrcpy((char far *)&buf[1],tcu->p->title);
if(mode) {
switch(mode1 = tcu->mode) {
case NEND: iro(IREND); break;
case NSEPA: if(tcu->p->top == tcu->p->tail) {
iro(IRSEPA); break;
}
default: switch(tcu->flag & ~(FTAG+FYOMI+FCYCLE)) {
case FSENTAKU: iro(IRSENTAKU);
buf[0] = '+';
break;
case FSAKUJYO: iro(IRSAKUJYO);
buf[0] = 'd';
break;
case FSENTAKU+FSAKUJYO: iro(IRGATTAI);
buf[0] = '*';
break;
default: if(tcu->flag & FTAG) iro(IRTAG);
else if(tcu->flag & FYOMI) {
iro(IRYOMI);
buf[0] = '-';
}
else if(mode1 >= NHPHEAD) iro(IRHEAD);
else iro(IRETC);
break;
}
}
}
else {
switch(mode1 = tcu->mode) {
case NEND: iro(IEND); break;
case NSEPA: if(tcu->p->top == tcu->p->tail) {
iro(ISEPA); break;
}
default: switch(tcu->flag & ~(FTAG+FYOMI+FCYCLE)) {
case FSENTAKU: iro(ISENTAKU);
buf[0] = '+';
break;
case FSAKUJYO: iro(ISAKUJYO);
buf[0] = 'd';
break;
case FSENTAKU+FSAKUJYO: iro(IGATTAI);
buf[0] = '*';
break;
default: if(tcu->flag & FTAG) iro(ITAG);
else if(tcu->flag & FYOMI) {
iro(IYOMI);
buf[0] = '-';
}
else if(mode1 >= NHPHEAD) iro(IHEAD);
else iro(IETC);
break;
}
}
}
strncat80(buf,space);
print(buf);
deforutoiro();
}
static void title2disp(PCELL far *po) /* タイトル一行表示 */
{
char buf[81],mode;
memset(buf,0,81);
sprintf(buf," ");
tbl_set(po);
_fstrcpy((char far *)&buf[1],po->p->title);
switch(mode = po->mode) {
case NEND: iro(IEND); break;
case NSEPA: if(po->p->top == po->p->tail) {
iro(ISEPA); break;
}
default: switch(po->flag & ~(FTAG+FYOMI+FCYCLE)) {
case FSENTAKU: iro(ISENTAKU);
buf[0] = '+';
break;
case FSAKUJYO: iro(ISAKUJYO);
buf[0] = 'd';
break;
case FSENTAKU+FSAKUJYO: iro(IGATTAI);
buf[0] = '*';
break;
default: if(po->flag & FTAG)
iro(ITAG);
else if(po->flag & FYOMI) {
iro(IYOMI);
buf[0] = '-';
}
else if(mode >= NHPHEAD)
iro(IHEAD);
else iro(IETC);
break;
}
}
strncat80(buf,space);
print(buf);
deforutoiro();
}
static void getgtail(PCELL far *tcu) /* 最終タイトル行を求める */
{
PCELL far *pt;
int k;
while(1) {
for(k = 3,pt = ggtop;pt && k <= line-2;pt=pt->next) {
if(!pt->count) continue;
k++;
}
if(pt) ggtail = pt->back;
else ggtail = p_tail;
if(ggtop->count <= tcu->count && ggtail->count >= tcu->count)
return;
for(ggtop = ggtail->next;!ggtop->count;ggtop=ggtop->next);
}
}
static void tstatus(PCELL far *tcu) /* タイトル状態表示 */
{
int i,j,k;
i = tcu->count;
j = ttail->count;
k = ggtail->count;
tbl_set(tcu);
kensakukensu = tcu->p->cmt;
nstatus(0,tcu,i,j,k,0);
}
static int jumpck(PCELL far *tcu) /* 次のタイトル位置チェック */
{
if(tcu->mode == NSEPA) return(0);
if(tcu->mode == NEND) return(1);
tbl_set(tcu);
if(tcu->p->top == tcu->p->tail) return(0);
if(!nextmode) return(1);
if(tcu->mode >= NHPHEAD) return(0);
if(nextmode > 1 && (tcu->flag & FYOMI)) return(0);
return(1);
}
static PCELL far *bfindfile(int n) /* ファイル前サーチ */
{
PCELL far *pt;
for(pt = ttail->back;pt->count != 1;pt=pt->back) {
if(!pt->count)
continue;
tbl_set(pt);
if(pt->p->fno <= n)
break;
}
return(pt);
}
static PCELL far *findfile(int n) /* ファイル次サーチ */
{
PCELL far *pt;
xhpread(MAXPOINT);
for(pt=p_top;pt->mode != NEND;pt=pt->next) {
if(!pt->count)
continue;
tbl_set(pt);
if(pt->p->fno >= n)
break;
}
return(pt);
}
static int titledisp(long bigin) /* タイトル表示 */
{
char a,c;
int i,rtn;
PCELL far *tcu;
PCELL far *w;
char buf[129];
tmode = 1;
if(startmode >= 4 && startmode <= 7) coment(0,1);
ttop = p_head;
ttail = p_tail;
switch(bigin) {
case -2:
if(pend != 2) w = ttop;
else {
for(w = ttail; w->back && w != ttop; w = w->back) {
if(w->mode >= NHPHEAD) continue;
if(!(w->flag & FYOMI)) continue;
break;
}
if(w != ttop && !(w->next->flag & FYOMI)) w = w->next;
}
break;
case -1:
if(pend != 2) w = ttop;
else {
for(w = ttop; w->next && w->mode != NEND; w = w->next) {
if(w->mode >= NHPHEAD) continue;
if(w->flag & FYOMI) continue;
break;
}
}
break;
case 0:
w = ttop;
break;
default:
for(w = ttop,i=0; w->mode != NEND; w = w->next) {
if(w->mode >= NHPHEAD) continue;
i++;
if(i > bigin) break;
w->flag |= FYOMI;
}
}
ggtop = tcu = w;
getgtail(tcu);
while(1) {
savepno = -1; /* タイトル一画面表示 */
topdisp();
pfdisp(0);
for(i = 3,w = ggtop;w && i <= line-2;w=w->next) {
if(!w->count) continue;
loc(1,i);
title2disp(w);
i++;
}
if(w) ggtail = w->back;
else ggtail = p_tail;
for(;i <= line-2;i++) {
loc(1,i);clr1(IETC);
}
keyreadt:
tstatus(tcu);
title1disp(tcu,1);
a = keyget2(1); /* キー読み込み */
a = cnvpfkey(a);
switch(a) {
case KAIGYO: /* 改行キー処理 */
tdisp1_1:
tstatus(tcu);
rtn = bundisp(tcu);
tdisp1_2:
tmode = 1;
pfset();
savepno = -1;
if(!rtn) {
if(!returnmode) {
if(ggtail->count < tcu->count || ggtop->count > tcu->count)
ggtop = tcu;
continue;
}
w = downtcu(ttail);
if(tcu->count < w->count) {
for(;;) {
tcu = uptcu0(tcu);
tbl_set(tcu);
if(tcu->p->top != tcu->p->tail || tcu->mode == NEND)
break;
}
}
title3disp(tcu);
continue;
}
if(rtn == -1) {
if(tcu->count <= ttop->count) {
ggtop = tcu = ttop;
continue;
}
for(;tcu->count > ttop->count;) {
tcu = downtcu(tcu);
if(jumpck(tcu))
break;
}
goto tdisp1_1;
/* if(rtn == -1) goto tdisp1_1;
tstatus(tcu);
rtn = bundisp(tcu,1);
goto tdisp1_2; */
}
if(rtn == -2) {
for(;tcu->count > ttop->count;) {
tcu = downtcu(tcu);
if(tcu->flag & FJUMP) {
tcu->flag &= ~FJUMP;
break;
}
}
goto tdisp1_1;
}
if(rtn == 1) {
w = downtcu(ttail);
if(tcu->count < w->count) {
for(;;) {
tcu = uptcu0(tcu);
if(jumpck(tcu)) break;
}
if(tcu->mode != NEND)
goto tdisp1_1;
}
title3disp(tcu);
continue;
}
if(rtn == 2) {
for(;;) {
tcu = uptcu0(tcu);
if(tcu->flag & FJUMP) {
tcu->flag &= ~FJUMP;
break;
}
}
goto tdisp1_1;
}
if(rtn <= -4) {
xfclose();
return(rtn);
}
break;
case UEYA: /* ↑キー処理 */
title1disp(tcu,0);
if(tcu->count > ggtop->count) {
tcu = downtcu(tcu);
break;
}
if(ggtop == ttop) break;
ggtop = tcu = downtcu(ggtop);
getgtail(tcu);
scldown();
loc(1,3);
title2disp(ggtop);
break;
case SITAYA: /* ↓キー処理 */
tsita:
title1disp(tcu,0);
if(tcu->count < ggtail->count) {
tcu = uptcu(tcu);
break;
}
if(ggtail == ttail) break;
xhpread(tcu->count+5);
ggtop = uptcu(ggtop);
tcu = uptcu(tcu);
sclup();
loc(1,line-2);
getgtail(tcu);
if(ggtail->count <= ttail->count)
title2disp(ggtail);
break;
case HIDARIYA: /* ←キー処理 */
if(tcu == ttop) break;
w = ggtop;
i = tcu->count - ggtop->count;
if(pagemode < 3) {
if(pagemode != 1) ggtop = mdowntcu(ggtop,line-4);
else {
ggtop = mdowntcu(ggtop,(line-4)/2);
i = i / 2;
}
getgtail(ggtop);
if(tcu->count > ggtail->count) tcu = muptcu(ggtop,i);
}
else {
ggtop = mdowntcu(ggtop,line-5);
getgtail(ggtop);
if(w == ggtop) tcu = ggtop;
else if(tcu->count > ggtail->count) tcu = ggtail;
}
continue;
case MIGIYA: /* →キー処理 */
if(tcu == ttail) break;
xhpread(ggtail->count+line);
i = tcu->count - ggtop->count;
w = ggtop;
if(pagemode < 3) {
if(pagemode != 1) ggtop = muptcu(ggtop,line-4);
else {
ggtop = muptcu(ggtop,(line-4)/2);
i = i / 2;
}
if(tcu->count < ggtop->count) tcu = muptcu(ggtop,i);
}
else {
if(ggtail != ttail) {
ggtop = muptcu(ggtop,line-5);
getgtail(ggtop);
if(w == ggtop) tcu = ggtail;
else if(tcu->count < ggtop->count) tcu = ggtop;
}
else tcu = downtcu(ttail);
}
continue;
case SENTAKU: /* 選択キー処理 */
if(!sentaku(tcu)) break;
goto tsita;
case ESC: /* ESCキー処理 */
if(nifmode != NFNORMAL) {
comentclr();
title3disp(tcu);
continue;
}
case PF1: /* 終了処理 */
if(!endcheck() && endmode) {
if(!yesnocheck("終了してもいいですか")) {
xhpread(ggtail->count+line);
ggtop = tcu;
continue;
}
}
xfclose();
return(0);
case PF2: /* 先頭行表示処理 */
if(ggtop == ttop) {
title1disp(tcu,0);
tcu = ggtop;
break;
}
ggtop = tcu = ttop;
continue;
case PF3: /* 最終行表示処理 */
xhpread(MAXPOINT);
if(ggtail == ttail) {
title1disp(tcu,0);
tcu = downtcu(ttail);
break;
}
tcu = downtcu(ttail);
ggtop = mdowntcu(tcu,line-5);
continue;
case PF4: /* ヘルプ処理 */
help(0);
continue;
case PF5: /* 切り出し処理 */
kiridasi(tcu);
continue;
case PF6: /* 削除処理 */
if(!(i=sakujyo(tcu))) break;
if(i == 1) continue;
goto tsita;
case PF7: /* コピー処理 */
fukusya(tcu);
continue;
case PF8: /* 検索処理 */
if(search(0)) {
ggtop = tcu = ttop = p_head;
ttail = p_tail;
continue;
}
continue;
case PF9: /* ID処理 */
if(idset(tcu)) {
title3disp(tcu);
continue;
}
break;
case PF10: /* コメント処理 */
if(w=coment(tcu,1)) {
tcu = w;
title3disp(tcu);
continue;
}
break;
case S_PF1: /* DOS呼び出し処理 */
if((i=oscall()) < 0) {
xfclose();
if(i == -1) return(-4);
return(-5);
}
continue;
case S_PF2: /* 前ファイル移動処理 */
tbl_set(tcu);
for(i=tcu->p->fno-1;i >= 1;i--) {
_fstrcpy((char far *)buf,file[i-1]);
if(checkfile(buf) == 1)
break;
}
if(i < 1)
goto nextfno;
if(startmode < 8) {
if(!endcheck()) xfclose();
return(-2);
}
w = bfindfile(i);
goto nextfno3;
case S_PF3: /* 次ファイル移動処理 */
tbl_set(tcu);
for(i=tcu->p->fno+1;i <= maxfno;i++) {
_fstrcpy((char far *)buf,file[i-1]);
if(checkfile(buf) == 1)
break;
}
if(i > maxfno) {
nextfno:
errdisp1(filenoterror);
break;
}
if(startmode < 8) {
if(!endcheck()) xfclose();
return(-3);
}
goto nextfno2;
case S_PF4: /* ファイル指定処理 */
if(!endcheck()) xfclose();
if(maxfno == 1) return(-1);
tbl_set(tcu);
i = filechoice(tcu->p->fno);
if(!i || startmode < 8)
return(i);
nextfno2:
w = findfile(i);
nextfno3:
ggtop = tcu = w;
continue;
case S_PF5: /* 選択取り消し処理 */
if(!torikesi())
break;
continue;
case S_PF6: /* 削除取り消し処理 */
if(!sakutorikesi())
break;
continue;
case S_PF7: /* タグセット処理 */
if(!tagset(tcu))
break;
continue;
case S_PF8: /* タグ前ジャンプ処理 */
if((w = tagmae(tcu))) {
tcu = w;
title3disp(tcu);
continue;
}
break;
case S_PF9: /* タグ後ろジャンプ処理 */
if((w = tagato(tcu))) {
tcu = w;
title3disp(tcu);
continue;
}
break;
case S_PF10: /* 発言処理 */
bunget(tcu,1);
hatugen(tcu,0);
bunbuffree();
continue;
case C_PF1: /* 強制出力付き終了処理 */
c = foutmode;
foutmode |= F_UPDATE;
if(!endcheck() && endmode) {
if(!yesnocheck("終了してもいいですか")) {
ggtop = tcu;
foutmode = c;
continue;
}
}
xfclose();
return(0);
case C_PF2: /* タイトル出力処理 */
titleout();
continue;
case C_PF3: /* 前検索ジャンプ処理 */
if((w = shmae(tcu,1))) {
tcu = w;
title3disp(tcu);
}
continue;
case C_PF4: /* 後ろ検索ジャンプ処理 */
if((w = shato(tcu,1))) {
tcu = w;
title3disp(tcu);
}
continue;
case C_PF5: /* 印刷処理 */
printsub(tcu);
continue;
case C_PF6: /* ログ整理(大分類)処理 */
logedit(0);
continue;
case C_PF7: /* ログ整理(詳細分類)処理 */
logedit(1);
continue;
case C_PF8: /* 行数切り換え処理 */
chgline(tcu);
title3disp(tcu);
continue;
case C_PF9: /* 利用者コマンド処理 */
if((i=usertouroku(tcu,1)) < 0) {
xfclose();
if(i == -1) return(-4);
return(-5);
}
continue;
case C_PF10: /* 自動表示処理 */
if((w = autodisp(tcu))) {
tcu = w;
title3disp(tcu);
continue;
}
break;
case SC_PF1: /* 既読記憶出力せず終了 */
i = midokumode;
midokumode |= 2;
if(!endcheck() && endmode) {
if(!yesnocheck("終了してもいいですか")) {
ggtop = tcu;
midokumode = i;
continue;
}
}
xfclose();
return(0);
case SC_PF2: /* ジャンプ10処理 */
if((w = nextjump(tcu,9))) {
tcu = w;
title3disp(tcu);
continue;
}
break;
case SC_PF3: /* ジャンプ20処理 */
if((w = nextjump(tcu,19))) {
tcu = w;
title3disp(tcu);
continue;
}
break;
case SC_PF4: /* ジャンプ50処理 */
if((w = nextjump(tcu,49))) {
tcu = w;
title3disp(tcu);
continue;
}
break;
case SC_PF5: /* 既読セット処理 */
if(kidokuset(tcu)) {
title3disp(tcu);
continue;
}
break;
case SC_PF6: /* 既読キャンセル処理 */
if(kidokucancel(tcu)) {
title3disp(tcu);
continue;
}
break;
case SC_PF7: /* ジャンプモード切替え処理 */
jumpmodechg();
continue;
case SC_PF8: /* タイプ処理 */
typedisp(tcu);
continue;
case SC_PF9: /* コメント+ID処理 */
if(comentid(tcu)) {
title3disp(tcu);
continue;
}
break;
case SC_PF10: /* 発言2処理 */
bunget(tcu,1);
hatugen(tcu,1);
bunbuffree();
continue;
default: /* 無効キー処理 */
break;
}
goto keyreadt;
}
}
static char *equsearch(char *buf)
{
char *op;
if((op = jstrchr(buf,'='))) op++;
else op = "";
return(op);
}
static int envsetsub0(char *o)
{
int w;
if(!isdigit(o[0])) return(0);
w = o[0] - '0';
if(!o[1] || !isdigit(o[1])) return(w);
w = w*10 +(o[1] - '0');
if(!o[2] || !isdigit(o[2])) return(w);
w = w*10 +(o[2] - '0');
return(w);
}
static int envsetsub1(char *o)
{
if(isdigit(o[0])) return(o[0] - '0');
else return(0);
}
#define MAXPARACK 52
static char *parack[MAXPARACK] = {
"エ",
"行",
"タイプ",
"切り出し",
"発言先",
"キ",
"色",
"ロ",
"ヘッダ文",
"フッタ文",
"メッセージ文",
"ヘッダ2",
"フッタ2",
"メッセージ2",
"確認",
"コ",
"利",
"タイトル出",
"Y",
"強",
"修",
"戻",
"ジ",
"マ",
"時",
"カ",
"バ",
"印刷プロ",
"起",
"待",
"自",
"読",
"V",
"ソートモ",
"ソート2",
"頁",
"ツ",
"T",
"先",
"タイト",
"記",
"未",
"タイトル表",
"セパ",
"印刷セパ",
"サフ",
"PF",
"ログ",
"タイム",
"ESC",
"EMS",
"フォーラム"
};
static int envsetsub2(char *buf)
{
int i;
for(i=0;i < MAXPARACK;i++) {
if(!xstrncmp(buf,parack[i]))
return(i);
}
return(-1);
}
static int cnv16(char o)
{
int i;
i = (int)o;
if(i >= '0' && i <= '9') i -= '0';
else if(i >= 'a' && i <= 'f') i -= 'a'-10;
else if(i >= 'A' && i <= 'F') i -= 'A'-10;
else i = 0;
return(i);
}
static void envsetsub3(FILE *fd1,char *buf)
{
char *o,*op,*p;
int i,w,k;
char work[51];
o = equsearch(buf);
i = envsetsub2(buf);
switch(i) {
case 0: /* "エ" */
if(o) xxstrncpy(editer,o,40);
return;
case 1: /* "行" */
if(o) line = envsetsub0(o);
return;
case 2: /* "タイプ" */
if(o) typespeed = envsetsub0(o);
return;
case 3: /* "切り出し" */
if(o) xxstrncpy50(kiridir,o);
return;
case 4: /* "発言先" */
if(o) xxstrncpy50(hatudir,o);
return;
case 5: /* "キ" */
for(k=0;k < 256;k++)
keytbl[k] = 0;
for(k=0;k < 47 && fgets(buf,81,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
i = k;
if(i < 10) i += 0x81;
else if(i < 20) i += 0xa1-10;
else if(i < 30) i += 0xc1-20;
else if(i < 40) i += 0xf5-30;
else if(i < 44) i += 0x90-40;
else if(i == 44) i = 0xff;
else if(i == 45) i = 0x0d;
else i = 0x1b;
if(*o) {
for(;*o;) {
op = jstrchr(o,',');
if(!op) {
op = o;
op += strlen(o);
}
else *op++ = 0;
if(o[0] == 0x27 && o[1]) {
w = (int)o[1];
}
else if(o[0] == '^' && o[1] >= '@' && o[1] <= '_') {
w = (int)(o[1] - '@');
}
else if(o[0]) {
w = cnv16(o[0]);
if(o[1]) w = w*16 + cnv16(o[1]);
}
keytbl[w] = i;
o = op;
}
}
else {
if(k < 40) {
keytbl[i] = 0;
}
}
k++;
}
return;
case 6: /* "色" */
for(i=0;i < IROMAX && fgets(buf,81,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(w = envsetsub0(o)) {
/* if(w < 0 || w > 63) w = 7; */
irotbl[i] = w;
}
i++;
}
return;
case 7: /* "ロ" */
for(i=0;i < LOGDIRMAX && fgets(buf,81,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(o[0]) {
if(!(logdir[i]=farmalloc(strlen(o)+1))) {
errdisp1(memgeterror);
break;
}
_fstrcpy(logdir[i],(char far *)o);
}
i++;
if(i == LETC+1) fgets(buf,81,fd1);
}
return;
case 8: /* "ヘッダ文" */
for(i=0;i < 4 && fgets(buf,257+13,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(o[0]) strcpy(hatutop[0][i],o);
i++;
}
return;
case 9: /* "フッタ文" */
for(i=0;i < 4 && fgets(buf,257+13,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(o[0]) strcpy(hatuend[0][i],o);
i++;
}
return;
case 10: /* "メッセージ文" */
for(i=0;i < 4 && fgets(buf,21+13,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(o[0]) strcpy(messtring[0][i],o);
i++;
}
return;
case 11: /* "ヘッダ2" */
for(i=0;i < 4 && fgets(buf,257+13,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(o[0]) strcpy(hatutop[1][i],o);
i++;
}
return;
case 12: /* "フッタ2" */
for(i=0;i < 4 && fgets(buf,257+13,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(o[0]) strcpy(hatuend[1][i],o);
i++;
}
return;
case 13: /* "メッセージ2" */
for(i=0;i < 4 && fgets(buf,21+13,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(o[0]) strcpy(messtring[1][i],o);
i++;
}
return;
case 14: /* "確認" */
if(o) endmode = envsetsub1(o);
return;
case 15: /* "コ" */
for(i=0;i < 3 && fgets(buf,129+13,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(o[0]) strcpy(kiridashitop[i],o);
i++;
}
return;
case 16: /* "利" */
for(i=0;i < 15 && fgets(buf,129+13,fd1);) {
rtncut(buf);
if(!isalnum(buf[0])) return;
if(buf[0] == ';') return;
o = equsearch(buf);
if(o[0]) strncpy(cmdtbl[i],o,40);
i++;
}
return;
case 17: /* "タイトル出" */
if(o) xxstrncpy50(titledir,o);
return;
case 18: /* "Y" */
if(o) yesnomode = envsetsub1(o);
return;
case 19: /* "強" */
if(o) sakujyomode = envsetsub1(o);
return;
case 20: /* "修" */
if(o) editmode = envsetsub1(o);
return;
case 21: /* "戻" */
if(o) returnmode = envsetsub1(o);
return;
case 22: /* "ジ" */
if(o) nextmode = envsetsub1(o);
return;
case 23: /* "マ" */
if(o) tabcrmode = envsetsub1(o);
return;
case 24: /* "時" */
if(o) jikokumode = envsetsub1(o);
return;
case 25: /* "カ" */
if(o) cutmode = envsetsub1(o);
for(i=0;i < MAXCUTNO && fgets(buf,81,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
if(!(cutstrtbl[i]=farmalloc(strlen(buf)+1)))
errdisp1(memgeterror);
else _fstrcpy(cutstrtbl[i],(char far *)buf);
i++;
}
return;
case 26: /* "バ" */
if(o) {
for(i=k=0;o[i] && k < 50;i++) {
if(iskanji(o[i]) && iskanji2(o[i+1])) {
bakdir[k++] = o[i++];
bakdir[k++] = o[i];
continue;
}
if(o[i] == '%') {
op = &o[i+1];
if(p = jstrchr(op,'%')) {
*p++ = 0;
strcpy(work,op);
strupr(work);
i += strlen(op) + 1;
if(op = getenv(work)) {
strcpy(&bakdir[k],op);
k += strlen(op);
}
continue;
}
}
bakdir[k++] = o[i];
}
bakdir[k] = 0;
}
return;
case 27: /* "印刷プロ" */
if(o) xxstrncpy(printprg,o,40);
return;
case 28: /* "起" */
if(o) startmode = envsetsub1(o);
return;
case 29: /* "待" */
if(o) waittimes = envsetsub1(o);
return;
case 30: /* "自" */
if(o) autodisptime2 = envsetsub0(o);
return;
case 31: /* "読" */
if(o) titlecount = envsetsub0(o);
return;
case 32: /* "V" */
if(o) vrammode = envsetsub1(o);
return;
case 33: /* "ソートモ" */
if(o) fsortmode = envsetsub1(o);
return;
case 34: /* "ソート2" */
if(o) fsort2mode = envsetsub1(o);
return;
case 35: /* "頁" */
if(o) pagemode = (char)envsetsub1(o);
return;
case 36: /* "ツ" */
if(o)
for(w=0;o[w*2] && w<4;w++) {
treechar[w*3] = o[w*2];
treechar[w*3+1] = o[w*2+1];
treechar[w*3+2] = 0;
}
return;
case 37: /* "T" */
if(o) tabno = envsetsub1(o);
return;
case 38: /* "先" */
if(o) topendmode = envsetsub1(o);
return;
case 39: /* "タイト" */
if(o) xxstrncpy(touttop,o,128);
return;
case 40: /* "記" */
if(o) xxstrncpy(datfile,o,128);
return;
case 41: /* "未" */
if(o) tagmode = (char)envsetsub1(o);
return;
case 42: /* "タイトル表" */
if(o) titlemode = (char)envsetsub1(o);
return;
case 43: /* "セパ" */
if(o) sepamode = (char)envsetsub1(o);
return;
case 44: /* "印刷セパ" */
if(o) xxstrncpy(prtsepa,o,128);
return;
case 45: /* "サフ" */
for(i=0;i < 2 && fgets(buf,129+13,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(o[0]) {
if(i == 0) strncpy(savsafix,o,3);
else strncpy(nifsafix,o,3);
}
i++;
}
return;
case 46: /* "PF" */
if(o) keyshiftmode = (char)envsetsub1(o);
return;
case 47: /* "ログ" */
if(o) passmode = (char)envsetsub1(o);
return;
case 48: /* "タイム" */
if(o) timechkmode = (char)envsetsub1(o);
return;
case 49: /* "ESC" */
for(i=0;i < 2 && fgets(buf,128,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
o = equsearch(buf);
if(*o) {
if(i == 0) op = ESCin;
else op = ESCout;
for(;*o;) {
if(o[0] == '^' && o[1] != '^') {
*op++ = (char)o[1] - 0x40;
o++;
}
else *op++ = *o;
o++;
}
*op = 0;
}
i++;
}
return;
case 50: /* "EMSページ数" */
if(o) emsno = (char)envsetsub0(o);
return;
case 51: /* "フォーラム" */
for(i=0;i < MAXMSGNO && fgets(buf,81,fd1);) {
rtncut(buf);
if(!isdigit(buf[0])) return;
if(!(msgstrtbl[i]=farmalloc(strlen(buf)+1)))
errdisp1(memgeterror);
else _fstrcpy(msgstrtbl[i],(char far *)buf);
i++;
}
return;
}
}
static char path[256];
static int envset(char **argv) /* 環境ファイル読み込み */
{
FILE *fd1;
char c,*o,buf[300];
long ep;
int i;
for(ep = 0;ep < FMAXFILE;ep++)
file[ep] = (char far *)0;
for(ep = 0;ep < MAXDATF;ep++)
datf[ep] = (char far *)0;
for(ep = 0;ep < LOGDIRMAX;ep++)
logdir[ep] = (char far *)0;
for(ep = 0;ep < 4;ep++) {
hatutop[0][ep][0] = hatutop[1][ep][0] = 0;
hatuend[0][ep][0] = hatuend[1][ep][0] = 0;
messtring[0][ep][0] = messtring[1][ep][0] = 0;
}
for(ep = 0;ep < 3;ep++)
kiridashitop[ep][0] = 0;
for(ep = 0;ep < 15;ep++)
memset(cmdtbl[ep],0,41);
for(ep = 0;ep < MAXCUTNO;ep++)
cutstrtbl[ep] = (char far *)0;
for(ep = 0;ep < MAXMSGNO;ep++)
msgstrtbl[ep] = (char far *)0;
for(i=0;i<4;i++)
treechar[i*3+2] = 0;
memset(filename,0,129);
for(i=0;(c=argv[0][i]);i++) {
if (c == '.') break;
path[i] = c;
}
path[i] = 0;
strcat(path,".cfg");
if(!(fd1 = fopen(path,"rt"))) {
if(!(o = searchpath("NIFP.CFG")))
return(1);
strcpy(path,o);
if(!(fd1 = fopen(path,"rt")))
return(1);
}
if(fgets(buf,256,fd1)) {
if(xstrncmp(&buf[1],cfgversion)) {
fclose(fd1);
return(2);
}
}
else {
fclose(fd1);
return(1);
}
for(;fgets(buf,256,fd1);) {
if(buf[0] == ';') continue;
rtncut(buf);
envsetsub3(fd1,buf);
}
fclose(fd1);
return(0);
}
static void main_sub1(char *buf,char batmode)
{
if(!batmode) {
loc(10,5);
eprintf(buf);
loc(10,6);
eprintf("何かキーを押してください。");
keyget();
}
else {
printf("\n\033[31m%s\033[0m\n",buf);
}
}
static void tbl_rtn(void)
{
PCELL far *pp;
PCELL3 far *pt1;
PCELL3 far *wk;
if(rsv_p) {
tbl_free(rsv_p);
rsv_p = (PCELL far *)0;
}
if(emsno) {
ems_free();
}
else {
for(pp = p_freetop;pp;pp=pp->next) {
if(!pp->lno)
farfree(pp->p);
}
p_freetop = (PCELL far *)0;
}
for(pt1 = p_tbltop;pt1;) {
wk = pt1->next;
farfree(pt1);
pt1 = wk;
}
p_tbltop = (PCELL3 far *)0;
}
static int handler(void)
{
hardresume(0);
}
int main (int argc, char **argv) /* NIFPメイン */
{
FILE *fd1;
int rcode,i,j,k,l,lmode;
long ep;
char a,fname[129],buf[180],*w;
int savefno;
PCELL far *pp;
PCELL far *wp;
char batmode=0,*fmode=(char *)0;
PCELL3 far *pt1;
PCELL3 far *wk;
struct stat sbuf;
segread(&sregs);
harderr((int (*)())handler);
switch(envset(argv)) {
case 1: main_sub1("NIFP.CFGファイルが見つかりません。",batmode);
break;
case 2: main_sub1("NIFP.CFGファイルの版数が違っています。",batmode);
break;
}
for(k=1,l=0,j=argc;k < j;k++) {
if(*argv[k] == '-' && !*(argv[k]+2)) {
switch(*(argv[k]+1)) {
case 'a':
case 'A': fmode = argv[++k]; break;
case 'm': midokumode |= 1; break;
case 'M': midokumode |= 2; break;
case 'o':
case 'O': batmode = 1; break;
case 'p':
case 'P': batmode = 2; break;
case 'x':
case 'X': startmode = 8; break;
case 'c': startmode = (startmode & 1) + 6; break;
case 'C': startmode = (startmode & 1) + 4; break;
}
}
else {
l++;
}
}
if(startmode >= 8) tagmode = 0;
if(!batmode) {
setcon(0);
csloff();
saveline = getline();
switch(line) {
case 1: chglowline(); break;
case 2: chghighline(); break;
}
line = getline();
setline(line);
line = getline();
allclr();
nifmode = NFNORMAL;
topdisp();
}
if(l == 1) {
for(i=1;i < argc;i++) {
if(argv[i][0] != '-') break;
}
if(i >= argc) i--;
w = argv[i];
strcpy(filename,w);
if(!checkfile(filename))
argc = 1;
}
if(fmode) {
fd1 = fopen(fmode, "rt");
if(!fd1) {
main_sub1("指定ファイルリストがオープンできません。",batmode);
goto owari;
}
for(j = 0;j < FMAXFILE;) {
if(!(fgets(buf,81,fd1)))
break;
rtncut(buf);
if(w = jstrchr(buf,' '))
*w = 0;
if(checkfile(buf) == 1) {
if(set2_tree(buf)) continue;
j++;
}
}
fclose(fd1);
if(!j) {
main_sub1(filenoerror,batmode);
goto owari;
}
for(i = 0,tree2_pos = tree2_top; i < j;) {
if(tree2_pos->file) {
file[i++] = tree2_pos->file;
}
else j--;
tree2_pos = tree2_pos->next;
}
maxfno = j;
tree2free();
if(j == 1) _fstrcpy((char far *)filename,file[0]);
}
else {
if(l <= 1) maxfno = 1;
else {
for(i = 1,j = 0;i < argc && j < FMAXFILE;i++) {
if(argv[i][0] == '-') continue;
strcpy(buf,argv[i]);
if(checkfile(buf) == 1) {
if(set2_tree(buf)) continue;
j++;
}
}
if(!j) {
main_sub1(filenoerror,batmode);
if(batmode) goto owari;
else goto fileset;
}
for(i = 0,tree2_pos = tree2_top; i < j;) {
if(tree2_pos->file) {
file[i++] = tree2_pos->file;
}
else j--;
tree2_pos = tree2_pos->next;
}
maxfno = j;
tree2free();
if(j == 1) _fstrcpy((char far *)filename,file[0]);
}
}
fno = 1;
if(!batmode) {
if((tagmode == 1) || (tagmode == 2)) {
if(fd1 = fopen(datfile,"rt")) {
for(i=0;fgets(buf,140,fd1);i++) {
rtncut(buf);
if(!(datf[i] = farmalloc(strlen(buf)+1))) {
main_sub1(memgeterror,batmode);
break;
}
_fstrcpy(datf[i],(char far *)buf);
}
fclose(fd1);
}
}
/* setline(line);
line = getline();
allclr();
nifmode = NFNORMAL;
topdisp(); */
if((startmode < 8) && (startmode & 1) && (maxfno > 1))
fno = filechoice(1);
}
/* ems_count = 0;
p_tbltop = (PCELL3 far *)0;
p_freetop = (PCELL far *)0;
if(emsno) {
if(ems_check()) {
if(tbl_alloc(1) == (PCELL far *)0) {
emsno = 0;
}
}
else {
emsno = 0;
}
}
if(!emsno) {
if(tbl_alloc(1) == (PCELL far *)0) {
main_sub1(memgeterror,batmode);
goto owari;
}
} */
lmode = 0;
for(;fno && fno <= maxfno;) {
/* if(!rsv_p) {
rsv_p = tbl_alloc(0);
if(!rsv_p) {
main_sub1(memgeterror,batmode);
goto owari;
}
} */
if(argc == 1)
goto fileset;
start:
if(!batmode) {
allclr();
nifmode = NFNORMAL;
tmode = 1;
pfset();
topdisp();
}
if(maxfno > 1) _fstrcpy((char far *)filename,file[fno-1]);
fd = xfopen(filename);
if(!fd) {
sprintf(buf,"%sファイルがオープンできません。",gfilename);
main_sub1(buf,batmode);
if(maxfno == 1) {
if(batmode) goto owari;
else goto fileset;
}
if(lmode) {
fno--;
if(fno < 1)
goto owari;
}
else {
fno++;
if(fno > maxfno)
goto owari;
}
continue;
}
stat(filename,&sbuf);
saveatime = sbuf.st_atime;
cfno = fno;
p_top=p_head=p_tail=(PCELL far *)0;
if(!batmode) {
deforutoiro();
stsdisp();
loc(39,line-1);iro(ILINE);
if(!erron) {
sprintf(buf," %3d/%3dファイル 0/ 0タイトル ----- ライン ",fno,maxfno);
print(buf);
}
}
else
printf("%sファイルのログを読み込み処理中です。\n",filename);
ems_count = 0;
p_tbltop = (PCELL3 far *)0;
p_freetop = (PCELL far *)0;
if(emsno) {
if(ems_check()) {
if(tbl_alloc(1) == (PCELL far *)0) {
emsno = 0;
}
}
else {
emsno = 0;
}
}
if(!emsno) {
if(tbl_alloc(1) == (PCELL far *)0) {
main_sub1(memgeterror,batmode);
goto owari;
}
}
if(!rsv_p) {
rsv_p = tbl_alloc(0);
if(!rsv_p) {
main_sub1(memgeterror,batmode);
goto owari;
}
}
p = 0;
p_linecount = 0;
sentakuno = 0;
sakujyono = 0;
tagno = 0;
savepno = -1;
gp = 0;
savehpread=0;
jumpon=1;
jpp = savepp = fsavepp = 0;
jpplno = savepplno = 0;
nmode = 0;
foutmode = 0;
hpid[0] = 0;
niftyid[0] = 0;
hpmsg[0] = 0;
forummsg[0] = 0;
forumname[0] = 0;
heya[0] = 0;
preno=0;
saveheya[0] = 0;
savebuf[0] = 0;
fmeslibno = 0;
pend = 0;
sp = 0;
passflag = 0;
logproc = 0;
forum3msgp = 0;
k = -1;
memset(datfile_s,0,140);
if(!fupmode && ((tagmode == 1) || (tagmode == 2)))
k = datf_src(filename,1);
savefno = fno;
if(batmode) {
erron=2;
hpread(MAXPOINT,0);
}
else if((k != -1) || startmode > 1) hpread(MAXPOINT,fupmode+1);
else hpread(line,fupmode+1);
fno = savefno;
if(!p) {
xfclose();
main_sub1("ログデータがありません。",batmode);
tbl_rtn();
if(maxfno == 1 || startmode >= 8) {
if(batmode) goto owari;
else goto fileset;
}
if(lmode) {
fno--;
if(fno < 1)
goto owari;
}
else {
fno++;
if(!batmode && fno > maxfno)
goto owari;
}
continue;
}
if(!batmode) {
ep = 0;
if(k != -1) {
_fstrcpy((char far *)buf,datf[k]);
w=jstrchr(buf,' ');
if(w[1] == '@') ep = atol(&w[2]);
else ep = atol(&w[1]);
}
if(tagmode == 3)
ep = -1;
if(tagmode == 4)
ep = -2;
rcode = titledisp(ep);
if(!fupmode && ((tagmode == 1) || (tagmode == 2))) {
if(k != -1) {
farfree(datf[k]);
datf[k] = 0;
}
else {
for(k=0;datf[k];k++)
;
}
if(midokuno) {
if(midokuno < 0)
sprintf(buf,"%s @%d",datfile_s,0-midokuno);
else
sprintf(buf,"%s %d",datfile_s,midokuno);
if(!(datf[k]=farmalloc(strlen(buf)+1)))
errdisp1(memgeterror);
else _fstrcpy(datf[k],(char far *)buf);
}
}
}
else {
logeditx(batmode-1);
xfclose();
rcode = -3;
}
for(pp = p_tail;pp;) {
wp = pp->back;
tbl_free(pp);
pp = wp;
}
tbl_rtn();
fupmode = 0;
if(!rcode) break;
if(rcode == -1) {
fileset:
sprintf(buf, "ログファイル名 = ");
fname[0] = 50;
strcpy(&fname[2],filename);
cgetfsx(buf, fname);
if(!fname[2])
break;
checkfile(&fname[2]);
strcpy(filename,&fname[2]);
lmode = 0;
goto start;
}
if(rcode == -2) {
lmode = 1;
fno--;
continue;
}
if(rcode == -4) {
fupmode = 1;
continue;
}
if(rcode == -5)
break;
if(rcode == -3)
fno++;
else
fno = rcode;
lmode = 0;
}
owari:
if(!batmode) {
if((tagmode == 1) || (tagmode == 2)) {
if(fd1 = fopen(datfile,"wt")) {
for(i=0;i < MAXDATF;i++) {
if(!datf[i]) continue;
_fstrcpy((char far *)buf,datf[i]);
if(!(w=jstrchr(buf,' '))) continue;
if(*(w+1) == '0') continue;
strcat(buf,"\n");
farfree(datf[i]);
if(fputs(buf,fd1) == EOF) break;
}
fclose(fd1);
}
}
setline(saveline);
restorecon(0);
allclr();
cslon();
if(printonoff) {
w = getenv("TMP");
strcpy(buf,"DEL ");
if(w) {
strcat(buf,w);
if(buf[strlen(buf)-1] != '\\') strcat(buf,"\\");
}
else strcat(buf,"\\");
strcat(buf,"$PR*.*");
system(buf);
ems_lno = -1;
}
}
for(ep = 0;file[ep] && ep < FMAXFILE;ep++)
farfree(file[ep]);
for(ep = 0;cutstrtbl[ep] && ep < MAXCUTNO;ep++)
farfree(cutstrtbl[ep]);
for(ep = 0;msgstrtbl[ep] && ep < MAXMSGNO;ep++)
farfree(msgstrtbl[ep]);
tbl_rtn();
}